All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: Jeff Layton <jlayton@poochiereds.net>
Cc: Vitaly Osipov <vitaly.osipov@gmail.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	linux-sparse@vger.kernel.org,
	Jeff Layton <jlayton@primarydata.com>
Subject: Re: [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression
Date: Fri, 13 Jun 2014 08:56:50 -0700	[thread overview]
Message-ID: <20140613155650.GA13426@thin> (raw)
In-Reply-To: <20140613080537.75635d81@f20.localdomain>

On Fri, Jun 13, 2014 at 08:05:37AM -0400, Jeff Layton wrote:
> On Thu, 12 Jun 2014 18:06:25 +1000
> Vitaly Osipov <vitaly.osipov@gmail.com> wrote:
> 
> > Nothing shows up for me on x86_64, allmodconfig, linux-next from 10 of
> > June. My sparse has been compiled from sources.
> > 
> > $ make fs/locks.o C=2 CHECK="/home/vosipov/bin/sparse"
> >   CHK     include/config/kernel.release
> >   CHK     include/generated/uapi/linux/version.h
> >   CHK     include/generated/utsrelease.h
> >   CALL    scripts/checksyscalls.sh
> >   CHECK   scripts/mod/empty.c
> >   CHECK   fs/locks.c
> > 
> > $ sparse —version
> > v0.5.0
> > 
> > $ which sparse
> > /home/vosipov/bin/sparse
> > 
> > Regards,
> > Vitaly
> > 
> > 
> > On Wed, Jun 11, 2014 at 11:51 PM, Jeff Layton <jlayton@poochiereds.net> wrote:
> > > On Wed, 11 Jun 2014 16:11:46 +0300
> > > Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > >
> > >> On Wed, Jun 11, 2014 at 07:06:32AM -0400, Jeff Layton wrote:
> > >> > $ rpm -q sparse
> > >> > sparse-0.5.0-1.fc20.x86_64
> > >> >
> > >> > I see it all over the tree, but an easy example is fs/locks.c:
> > >> >
> > >> > $ make fs/locks.o C=1
> > >> > make[1]: Nothing to be done for `all'.
> > >> > make[1]: Nothing to be done for `relocs'.
> > >> >   CHK     include/config/kernel.release
> > >> >   CHK     include/generated/uapi/linux/version.h
> > >> >   CHK     include/generated/utsrelease.h
> > >> >   CALL    scripts/checksyscalls.sh
> > >> >   CHECK   fs/locks.c
> > >> > include/linux/err.h:35:16: warning: dereference of noderef expression
> > >> > include/linux/err.h:30:23: warning: dereference of noderef expression
> > >> > include/linux/err.h:35:16: warning: dereference of noderef expression
> > >> > include/linux/err.h:30:23: warning: dereference of noderef expression
> > >> >   CC      fs/locks.o
> > >> >
> > >> > It has two IS_ERR calls and two PTR_ERR calls, and each generates the
> > >> > warning.
> > >> >
> > >>
> > >> I downloaded the Fedora SRPM and built the binary but I still wasn't
> > >> able to reproduce the bug.
> > >>
> > >> dcarpenter@speke:~/progs/kernel/devel$ /tmp/sparse/sparse-0.5.0/sparse --version
> > >> 0.5.0
> > >> dcarpenter@speke:~/progs/kernel/devel$ make C=2 CHECK=/tmp/sparse/sparse-0.5.0/sparse fs/locks.o
> > >>   CHK     include/config/kernel.release
> > >>   CHK     include/generated/uapi/linux/version.h
> > >>   CHK     include/generated/utsrelease.h
> > >>   CALL    scripts/checksyscalls.sh
> > >> <stdin>:1226:2: warning: #warning syscall finit_module not implemented [-Wcpp]
> > >> <stdin>:1229:2: warning: #warning syscall sched_setattr not implemented [-Wcpp]
> > >> <stdin>:1232:2: warning: #warning syscall sched_getattr not implemented [-Wcpp]
> > >> <stdin>:1235:2: warning: #warning syscall renameat2 not implemented [-Wcpp]
> > >>   CHECK   scripts/mod/empty.c
> > >>   CHECK   fs/locks.c
> > >> dcarpenter@speke:~/progs/kernel/devel$
> > >>
> > >> I'm on today's linux-next.  I can't think of a kernel configuration
> > >> issue which would cause this...
> > >>
> > >> regards,
> > >> dan carpenter
> > >
> > > Could it be arch-specific then? What arch are you using? I'm on x86_64.
> > > I know that quite a few other people have mentioned seeing these
> > > warnings as well, so I'm pretty sure it's not just me.
> > >
> 
> Ha! It turns out that my hand-built sparse also works fine, so the
> problem seems to be in the Fedora package.
> 
> With a little trial-and-error, I figured out what's causing the
> problem, but I'm a little baffled as to why it's occurring. 
> 
> The Fedora SRPM builds the program with -fpic. When I remove that flag,
> this problem goes away. I'd appreciate any insight into why that would
> break things. I doubt PIC really makes much difference security-wise in
> sparse, so removing it shouldn't matter much, but I wonder if this
> indicates an underlying bug in sparse itself?

Wow, that's horrifying.  I wonder if it might indicate a miscompilation
by GCC.  Does the problem persist if you build with -fpic -g?  If so,
you could set a few breakpoints and try to determine at what point the
behavior of the two sparse binaries diverges.

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-06-13 15:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10 21:38 [PATCH][RFC] err.h: silence sparse warning: dereference of noderef expression Jeff Layton
2014-06-11  5:45 ` Dan Carpenter
2014-06-11 11:06   ` Jeff Layton
2014-06-11 13:11     ` Dan Carpenter
2014-06-11 13:51       ` Jeff Layton
2014-06-12  8:06         ` Vitaly Osipov
2014-06-13 12:05           ` Jeff Layton
2014-06-13 15:56             ` Josh Triplett [this message]
2014-06-14 13:44               ` Jeff Layton
2014-06-14 14:05                 ` Vitaly Osipov
2014-06-14 16:47                   ` Jeff Layton

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=20140613155650.GA13426@thin \
    --to=josh@joshtriplett.org \
    --cc=dan.carpenter@oracle.com \
    --cc=jlayton@poochiereds.net \
    --cc=jlayton@primarydata.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=vitaly.osipov@gmail.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.