All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
@ 2018-07-05 15:57 Bart Van Assche
  2018-07-06 17:31 ` Luc Van Oostenryck
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2018-07-05 15:57 UTC (permalink / raw)
  To: Christopher Li
  Cc: linux-sparse, Bart Van Assche, Rasmus Villemoes, Kees Cook,
	Dan Carpenter, Luc Van Oostenryck, stable

Both sparse and smatch identify themselves as gcc. However, neither
static analyzer supports any of the __builtin_*_overflow() functions.
Hence do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for these
static checkers.

Fixes: f0907827a8a9 ("compiler.h: enable builtin overflow checkers and add fallback code")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Kees Cook <keescook@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: <stable@vger.kernel.org>
---
 include/linux/compiler-gcc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index f1a7492a5cc8..15e55b89e952 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -344,6 +344,6 @@
  */
 #define uninitialized_var(x) x = x
 
-#if GCC_VERSION >= 50100
+#if GCC_VERSION >= 50100 && !defined(__CHECKER__)
 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
 #endif
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
  2018-07-05 15:57 [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW Bart Van Assche
@ 2018-07-06 17:31 ` Luc Van Oostenryck
  2018-07-06 17:38   ` Bart Van Assche
  0 siblings, 1 reply; 6+ messages in thread
From: Luc Van Oostenryck @ 2018-07-06 17:31 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Christopher Li, linux-sparse, Rasmus Villemoes, Kees Cook,
	Dan Carpenter, stable

On Thu, Jul 05, 2018 at 08:57:26AM -0700, Bart Van Assche wrote:
> Both sparse and smatch identify themselves as gcc. However, neither
> static analyzer supports any of the __builtin_*_overflow() functions.
> Hence do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for these
> static checkers.
> 
> Fixes: f0907827a8a9 ("compiler.h: enable builtin overflow checkers and add fallback code")
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> Cc: <stable@vger.kernel.org>
> ---
>  include/linux/compiler-gcc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index f1a7492a5cc8..15e55b89e952 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -344,6 +344,6 @@
>   */
>  #define uninitialized_var(x) x = x
>  
> -#if GCC_VERSION >= 50100
> +#if GCC_VERSION >= 50100 && !defined(__CHECKER__)
>  #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
>  #endif
> -- 

Hi,

A similar patch has already been posted 2 or 3 weeks ago [1].

Also, the development version of sparse [2] supports the
__builtin_*_overflow() functions *and* supports the __has_builtin()
macro. So I think it's preferable to use __has_builtin(),
at least for sparse (maybe smatch is interested in it too).

-- Luc Van Oostenryck

[1] https://lore.kernel.org/lkml/alpine.LSU.2.21.1806071258310.7958@pobox.suse.cz/
[2] git://github.com/lucvoo/sparse.git

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
  2018-07-06 17:31 ` Luc Van Oostenryck
@ 2018-07-06 17:38   ` Bart Van Assche
  2018-07-06 22:46     ` Luc Van Oostenryck
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2018-07-06 17:38 UTC (permalink / raw)
  To: luc.vanoostenryck
  Cc: linux-sparse, linux, dan.carpenter, keescook, stable, sparse

On Fri, 2018-07-06 at 19:31 +0200, Luc Van Oostenryck wrote:
> On Thu, Jul 05, 2018 at 08:57:26AM -0700, Bart Van Assche wrote:
> > Both sparse and smatch identify themselves as gcc. However, neither
> > static analyzer supports any of the __builtin_*_overflow() functions.
> > Hence do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for these
> > static checkers.
> > 
> > Fixes: f0907827a8a9 ("compiler.h: enable builtin overflow checkers and add fallback code")
> > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> > Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> > Cc: Kees Cook <keescook@chromium.org>
> > Cc: Dan Carpenter <dan.carpenter@oracle.com>
> > Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> > Cc: <stable@vger.kernel.org>
> > ---
> >  include/linux/compiler-gcc.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> > index f1a7492a5cc8..15e55b89e952 100644
> > --- a/include/linux/compiler-gcc.h
> > +++ b/include/linux/compiler-gcc.h
> > @@ -344,6 +344,6 @@
> >   */
> >  #define uninitialized_var(x) x = x
> >  
> > -#if GCC_VERSION >= 50100
> > +#if GCC_VERSION >= 50100 && !defined(__CHECKER__)
> >  #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
> >  #endif
> > -- 
> 
> Hi,
> 
> A similar patch has already been posted 2 or 3 weeks ago [1].
> 
> Also, the development version of sparse [2] supports the
> __builtin_*_overflow() functions *and* supports the __has_builtin()
> macro. So I think it's preferable to use __has_builtin(),
> at least for sparse (maybe smatch is interested in it too).
> 
> -- Luc Van Oostenryck
> 
> [1] https://lore.kernel.org/lkml/alpine.LSU.2.21.1806071258310.7958@pobox.suse.cz/
> [2] git://github.com/lucvoo/sparse.git

Hello Luc,

Thanks, I had missed Miroslav's patch. BTW, which sparse repository do you
recommend that I pull from to obtain a recent and stable version of sparse? The
git://git.kernel.org/pub/scm/devel/sparse/sparse.git repository mentioned on
https://sparse.wiki.kernel.org/index.php/Main_Page, https://github.com/lucvoo/sparse
or https://github.com/lucvoo/sparse-dev?

Thanks,

Bart.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
  2018-07-06 17:38   ` Bart Van Assche
@ 2018-07-06 22:46     ` Luc Van Oostenryck
  2018-07-06 22:53       ` Bart Van Assche
  0 siblings, 1 reply; 6+ messages in thread
From: Luc Van Oostenryck @ 2018-07-06 22:46 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: linux-sparse, linux, dan.carpenter, keescook, stable, sparse

On Fri, Jul 06, 2018 at 05:38:33PM +0000, Bart Van Assche wrote:
> 
> Hello Luc,
> 
> Thanks, I had missed Miroslav's patch. BTW, which sparse repository do you
> recommend that I pull from to obtain a recent and stable version of sparse? The
> git://git.kernel.org/pub/scm/devel/sparse/sparse.git repository mentioned on
> https://sparse.wiki.kernel.org/index.php/Main_Page, https://github.com/lucvoo/sparse
> or https://github.com/lucvoo/sparse-dev?
> 
> Thanks,

The tree at:
	https://github.com/lucvoo/sparse-dev
is my own development/work-in-progrees tree. It mainly contains
my WIP topic branches. These branches are not stable and are rebased.
I mainly use this tree to share patch series for testing & review.

The official tree is the one on kernel.org:
	git://git.kernel.org/pub/scm/devel/sparse/sparse.git
and is stable and relatively recent but:
1) it lacks some essential patches to avoid tons of useless noises,
   like for example the patch:
	https://patchwork.kernel.org/patch/10334355/
2) it lacks numerous fixes and improvements, like these overflow
   builtins, but many others too.
3) Christopher, the maintainer, is AWOL since a few months. He even
   never sent an announcement for the last release.

So, I collect patches from myself and from others in the tree:
	  git://github.com/lucvoo/sparse.git
	https://github.com/lucvoo/sparse
This tree is stable, very well tested, never rebased and contains 
numerous fixes and improvements.

Of course, ideally, my stable tree should be merged into the official
tree, like Linus already asked Chris to do (twice). But for now,
I strongly suggest to use my stable & up-to-date tree on github:
	git://github.com/lucvoo/sparse.git

Sorry if the situation is a bit confusing. I'm far from being satisfied
with it myself.

-- Luc Van Oostenryck

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
  2018-07-06 22:46     ` Luc Van Oostenryck
@ 2018-07-06 22:53       ` Bart Van Assche
  2018-07-07  9:49         ` Luc Van Oostenryck
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2018-07-06 22:53 UTC (permalink / raw)
  To: luc.vanoostenryck
  Cc: linux-sparse, linux, dan.carpenter, keescook, stable, sparse

On Sat, 2018-07-07 at 00:46 +0200, Luc Van Oostenryck wrote:
> 1) it lacks some essential patches to avoid tons of useless noises,
>    like for example the patch:
> 	https://patchwork.kernel.org/patch/10334355/

Hello Luc,

To suppress the sizeof(void) warnings I sent the following patch to Linus:
"[PATCH] kernel.h: Avoid that sparse complains about using sizeof(void)"
(https://lore.kernel.org/lkml/20180705161709.17028-1-bart.vanassche@wdc.com/).
Please advise how to proceed with that patch.

Thanks,

Bart.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
  2018-07-06 22:53       ` Bart Van Assche
@ 2018-07-07  9:49         ` Luc Van Oostenryck
  0 siblings, 0 replies; 6+ messages in thread
From: Luc Van Oostenryck @ 2018-07-07  9:49 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: linux-sparse, linux, dan.carpenter, keescook, stable, sparse

On Fri, Jul 06, 2018 at 10:53:08PM +0000, Bart Van Assche wrote:
> On Sat, 2018-07-07 at 00:46 +0200, Luc Van Oostenryck wrote:
> > 1) it lacks some essential patches to avoid tons of useless noises,
> >    like for example the patch:
> > 	https://patchwork.kernel.org/patch/10334355/
> 
> Hello Luc,
> 
> To suppress the sizeof(void) warnings I sent the following patch to Linus:
> "[PATCH] kernel.h: Avoid that sparse complains about using sizeof(void)"
> (https://lore.kernel.org/lkml/20180705161709.17028-1-bart.vanassche@wdc.com/).
> Please advise how to proceed with that patch.

The problems I have with this patch are:
1) it increases the difference between the code as seen by sparse
   and the one seen by GCC. It's fine as temporary band-aid but this
   kind of patches tend to stay forever.
2) it shouldn't really be needed because someone, Joey Pabalinas,
   has already, several months ago, done what is needed on sparse's
   side to suppress this warning as soon as it became a problem.

Of course, the real solution would be to keep the maintenance pace
of sparse's official better in synch with the kernel development
Meanwhile, I understand very well the need of your patch.

-- Luc Van Oostenryck

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-07  9:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05 15:57 [PATCH] compiler.h, sparse, smatch: Do not define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW Bart Van Assche
2018-07-06 17:31 ` Luc Van Oostenryck
2018-07-06 17:38   ` Bart Van Assche
2018-07-06 22:46     ` Luc Van Oostenryck
2018-07-06 22:53       ` Bart Van Assche
2018-07-07  9:49         ` Luc Van Oostenryck

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.