Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-31 Thread Kees Cook
On Fri, Mar 30, 2018 at 10:34 PM, Ingo Molnar wrote: > > * Kees Cook wrote: > >> On Mon, Mar 26, 2018 at 10:47 PM, Ingo Molnar wrote: >> > >> > * Kees Cook wrote: >> > >> >> In the effort to remove all VLAs from the kernel[1], it is desirable to >> >> build with -Wvla. However, this warning is

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-30 Thread Ingo Molnar
* Kees Cook wrote: > On Mon, Mar 26, 2018 at 10:47 PM, Ingo Molnar wrote: > > > > * Kees Cook wrote: > > > >> In the effort to remove all VLAs from the kernel[1], it is desirable to > >> build with -Wvla. However, this warning is overly pessimistic, in that > >> it is only happy with stack arr

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-30 Thread Kees Cook
On Mon, Mar 26, 2018 at 10:47 PM, Ingo Molnar wrote: > > * Kees Cook wrote: > >> In the effort to remove all VLAs from the kernel[1], it is desirable to >> build with -Wvla. However, this warning is overly pessimistic, in that >> it is only happy with stack array sizes that are declared as consta

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-27 Thread kbuild test robot
Hi Kees, I love your patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v4.16-rc7 next-20180327] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/c

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-27 Thread Uecker, Martin
To give credit where credit is due, this hack was inspired by  an equally insane (but different) use of the ?: operator to choose  the right return type for type-generic macros in tgmath.h. https://sourceware.org/git/?p=glibc.git;a=blob;f=math/tgmath.h;h=a709a5 9d0fa1168ef03349561169fc5bd27d65aa;

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-27 Thread kbuild test robot
Hi Kees, I love your patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v4.16-rc7 next-20180326] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/c

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-27 Thread Miguel Ojeda
On Tue, Mar 27, 2018 at 12:15 AM, Kees Cook wrote: > In the effort to remove all VLAs from the kernel[1], it is desirable to > build with -Wvla. However, this warning is overly pessimistic, in that > it is only happy with stack array sizes that are declared as constant > expressions, and not const

RE: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-27 Thread David Laight
From: Kees Cook > Sent: 26 March 2018 23:16 ... > +#define __typecheck(x, y) \ > + (!!(sizeof((typeof(x)*)1 == (typeof(y)*)1))) The two 1 should probably be at least 8 before the compiler starts bleating about accesses to misaligned addresses being undefined. David

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-26 Thread Ingo Molnar
* Kees Cook wrote: > In the effort to remove all VLAs from the kernel[1], it is desirable to > build with -Wvla. However, this warning is overly pessimistic, in that > it is only happy with stack array sizes that are declared as constant > expressions, and not constant values. One case of this i

Re: [PATCH v6] kernel.h: Retain constant expression output for max()/min()

2018-03-26 Thread Linus Torvalds
On Mon, Mar 26, 2018 at 12:15 PM, Kees Cook wrote: > > This patch updates the min()/max() macros to evaluate to a constant > expression when called on constant expression arguments. Ack. I'm of two minds whether that "__is_constant()" macro should be explained or not. A small voice in my head s