mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Static analyzers results on musl
Date: Thu, 10 Oct 2013 12:06:44 -0400	[thread overview]
Message-ID: <20131010160644.GO20515@brightrain.aerifal.cx> (raw)
In-Reply-To: <alpine.LNX.2.00.1310042102540.6178@monopod.intra.ispras.ru>

On Fri, Oct 04, 2013 at 09:51:25PM +0400, Alexander Monakov wrote:
>  - 2 sizeof mismatch warnings make sense

These have been fixed (as well as at least one other that was not
caught).

>  - 19+1 "dead code" warnings are helpful

I think some of these have been fixed, but they are low priority.

>  - "Out-of-bound array access" in glob.c appears to be a false positive (?)

At first I thought this was possibly a real overflow, but it seems to
be caused by the invalid use of [1] instead of [] for a flexible array
member in struct match. That's a bug in itself, so I'll look into
fixing it, but need to be careful not to mess up the allocation size
logic at the same time.

>  - There are many "garbage"/"undefined" warnings where the variable in
>    question is passed to a syscall by reference and expected to be initialized
>    there, unless error is signalled; it's quite unfortunate to have many false
>    positives like that

At least one of these seems to be a valid error:

http://port70.net/~nsz/musl/clang-2013-10-04/report-c1ebd3.html#EndPath

Unless the compiler takes advantage of the fact that accessing
indeterminate values is not valid, this one should have zero impact,
but needs to be fixed. I think reordering the operands of && would fix
it.

This one is also semi-valid:

http://port70.net/~nsz/musl/clang-2013-10-04/report-edc7bc.html#EndPath

But the code path it's taken is where the application has provided an
invalid stack address for the new thread, such that after aligning it
mod 16 and subtracting off __pthread_tsd_size, the resulting address
is null. However, valid pointer arithmetic can never result in a null
pointer, so I think this is actually a bug in clang's static analysis.

Please let me know if this analysis seems wrong.

>  - I have not attempted to investigate "dereference of null" warnings

The ones in regex are pretty complex and I'm still unclear on whether
the code paths flagged by the analysis are actually possible. It
doesn't help that this is third-party code. As for wordexp, I need to
look again; it looked to me like the null pointer dereference path
might occur when there are errors communicating with the child
process.

> I also have results from another static analysis tool developed internally
> were I work.  Here's a few hand-picked additional warnings.  I ran the tool
> without updating git first, so the tree was from September 9 (commit ff4be70).
> Sorry about that.
> 
> setenv.c:21  malloc return value not checked

Fixed.

> vfprintf.c:664
> vfwprint.c:354  va_end not called on error return path

Fixed.

> regcomp.c:767
> regcomp.c:807  sizeof mismatch; don't know why not flagged by clang

Fixed.

> getifaddrs.c:92  the code trusts the kernel that the fifth token would not be
> longer than IFNAMSIZ :)

Still pending whether we should consider this case.

Rich


      parent reply	other threads:[~2013-10-10 16:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-04 17:51 Alexander Monakov
2013-10-04 18:18 ` Szabolcs Nagy
2013-10-04 20:21 ` Rich Felker
2013-10-04 21:10   ` Alexander Monakov
2013-10-04 21:32     ` Rich Felker
2013-10-04 21:39       ` Alexander Monakov
2013-10-05  2:01         ` Rich Felker
2013-10-10 16:06 ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131010160644.GO20515@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).