All of lore.kernel.org
 help / color / mirror / Atom feed
* sparse warnings in overflow.h
@ 2018-06-07 11:01 Miroslav Benes
  2018-06-07 18:35 ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Miroslav Benes @ 2018-06-07 11:01 UTC (permalink / raw)
  To: keescook; +Cc: linux-kernel


Hi Kees,

sparse (make C=1) gives me this warnings today...

./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow'
./include/linux/overflow.h:254:13: error: incorrect type in conditional
./include/linux/overflow.h:254:13:    got void
./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow'
./include/linux/overflow.h:256:13: error: incorrect type in conditional
./include/linux/overflow.h:256:13:    got void

This hunk obviously fixes it, but I'm really not sure if it is a proper 
fix.

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

Any idea?

Regards,
Miroslav

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

* Re: sparse warnings in overflow.h
  2018-06-07 11:01 sparse warnings in overflow.h Miroslav Benes
@ 2018-06-07 18:35 ` Kees Cook
  2018-06-07 19:25   ` Rasmus Villemoes
  2018-06-08  6:34   ` [PATCH] compiler-gcc.h: don't set COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for sparse Miroslav Benes
  0 siblings, 2 replies; 5+ messages in thread
From: Kees Cook @ 2018-06-07 18:35 UTC (permalink / raw)
  To: Miroslav Benes; +Cc: LKML, Rasmus Villemoes

On Thu, Jun 7, 2018 at 4:01 AM, Miroslav Benes <mbenes@suse.cz> wrote:
>
> Hi Kees,
>
> sparse (make C=1) gives me this warnings today...
>
> ./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow'
> ./include/linux/overflow.h:254:13: error: incorrect type in conditional
> ./include/linux/overflow.h:254:13:    got void
> ./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow'
> ./include/linux/overflow.h:256:13: error: incorrect type in conditional
> ./include/linux/overflow.h:256:13:    got void
>
> This hunk obviously fixes it, but I'm really not sure if it is a proper
> fix.
>
> 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
>
> Any idea?

Hi! Yeah, that's probably the correct approach. If the checker doesn't
have it, the builtins need to be disabled. :)

Can you send this with a Signed-off-by line, etc, and I'll take it for
sending to Linus?

Thanks!

-Kees

-- 
Kees Cook
Pixel Security

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

* Re: sparse warnings in overflow.h
  2018-06-07 18:35 ` Kees Cook
@ 2018-06-07 19:25   ` Rasmus Villemoes
  2018-06-07 23:45     ` Luc Van Oostenryck
  2018-06-08  6:34   ` [PATCH] compiler-gcc.h: don't set COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for sparse Miroslav Benes
  1 sibling, 1 reply; 5+ messages in thread
From: Rasmus Villemoes @ 2018-06-07 19:25 UTC (permalink / raw)
  To: Kees Cook, Miroslav Benes; +Cc: LKML

On 2018-06-07 20:35, Kees Cook wrote:
> On Thu, Jun 7, 2018 at 4:01 AM, Miroslav Benes <mbenes@suse.cz> wrote:
>>
>> Hi Kees,
>>
>> sparse (make C=1) gives me this warnings today...
>>
>> ./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow'
>> ./include/linux/overflow.h:254:13: error: incorrect type in conditional
>> ./include/linux/overflow.h:254:13:    got void
>> ./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow'
>> ./include/linux/overflow.h:256:13: error: incorrect type in conditional
>> ./include/linux/overflow.h:256:13:    got void
>>
>> This hunk obviously fixes it, but I'm really not sure if it is a proper
>> fix.
>>
>> 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
>>
>> Any idea?
> 
> Hi! Yeah, that's probably the correct approach. If the checker doesn't
> have it, the builtins need to be disabled. :)

IIRC, the problem is that sparse pretends to be the gcc sparse itself
was built with, which is obviously entirely unrelated to the C dialect
that that particular sparse version groks. Sigh. Ack to the fix above.

Rasmus

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

* Re: sparse warnings in overflow.h
  2018-06-07 19:25   ` Rasmus Villemoes
@ 2018-06-07 23:45     ` Luc Van Oostenryck
  0 siblings, 0 replies; 5+ messages in thread
From: Luc Van Oostenryck @ 2018-06-07 23:45 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: Kees Cook, Miroslav Benes, LKML

On Thu, Jun 07, 2018 at 09:25:09PM +0200, Rasmus Villemoes wrote:
> 
> IIRC, the problem is that sparse pretends to be the gcc sparse itself
> was built with, which is obviously entirely unrelated to the C dialect
> that that particular sparse version groks. Sigh. Ack to the fix above.

Yes, indeed, and it is sometimes a problem.
Ideal would be that sparse would pretend to be same GCC as the one used
to compile the code being checked *and* to have exactly the same features.

Pretending to be an older version of GCC would maybe solve the present
problem it's not really a general solution.

One good thing would be to not depend on GCC versions to enable some
features (but GCC offers few facilities helping here).


Best regards,
-- Luc Van Oostenryck

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

* [PATCH] compiler-gcc.h: don't set COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for sparse
  2018-06-07 18:35 ` Kees Cook
  2018-06-07 19:25   ` Rasmus Villemoes
@ 2018-06-08  6:34   ` Miroslav Benes
  1 sibling, 0 replies; 5+ messages in thread
From: Miroslav Benes @ 2018-06-08  6:34 UTC (permalink / raw)
  To: keescook; +Cc: linux, luc.vanoostenryck, linux-kernel, Miroslav Benes

sparse errors out with

./include/linux/overflow.h:254:13: error: undefined identifier '__builtin_mul_overflow'
./include/linux/overflow.h:254:13: error: incorrect type in conditional
./include/linux/overflow.h:254:13:    got void
./include/linux/overflow.h:256:13: error: undefined identifier '__builtin_add_overflow'
./include/linux/overflow.h:256:13: error: incorrect type in conditional
./include/linux/overflow.h:256:13:    got void

Sparse has not acquired generic overflow builtins yet, so don't set
COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for it.

Signed-off-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 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.17.0

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

end of thread, other threads:[~2018-06-08  6:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 11:01 sparse warnings in overflow.h Miroslav Benes
2018-06-07 18:35 ` Kees Cook
2018-06-07 19:25   ` Rasmus Villemoes
2018-06-07 23:45     ` Luc Van Oostenryck
2018-06-08  6:34   ` [PATCH] compiler-gcc.h: don't set COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for sparse Miroslav Benes

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.