Re: [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-04 Thread Kees Cook
On Thu, Jun 04, 2020 at 11:39:05PM +0200, Thomas Gleixner wrote: > Kees Cook writes: > >> > -#define NODE_NOT_IN_PAGE_FLAGS > >> > +#define NODE_NOT_IN_PAGE_FLAGS 1 > >> > >> but if we ever lose the 1 then the above will silently compile the code > >> within the IS_ENABLED() section out. > > > >

Re: [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-04 Thread Thomas Gleixner
Kees Cook writes: >> > -#define NODE_NOT_IN_PAGE_FLAGS >> > +#define NODE_NOT_IN_PAGE_FLAGS 1 >> >> but if we ever lose the 1 then the above will silently compile the code >> within the IS_ENABLED() section out. > > That's true, yes. I considered two other ways to do this: > > 1) smallest patch,

Re: [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-04 Thread Miguel Ojeda
On Thu, Jun 4, 2020 at 4:56 PM Kees Cook wrote: > > Er? That's not what it looked like to me: > > #define IS_BUILTIN(option) __is_defined(option) > #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) > > But just to be sure, I just tested in with a real build: > > [3.242160]

Re: [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-04 Thread Kees Cook
On Thu, Jun 04, 2020 at 01:41:07PM +0200, Miguel Ojeda wrote: > On Thu, Jun 4, 2020 at 9:58 AM Thomas Gleixner wrote: > > > > but if we ever lose the 1 then the above will silently compile the code > > within the IS_ENABLED() section out. > > Yeah, I believe `IS_ENABLED()` is only meant for Kconf

Re: [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-04 Thread Kees Cook
On Thu, Jun 04, 2020 at 09:58:07AM +0200, Thomas Gleixner wrote: > Kees Cook writes: > > -#ifdef NODE_NOT_IN_PAGE_FLAGS > > - pfn_align = node_map_pfn_alignment(); > > - if (pfn_align && pfn_align < PAGES_PER_SECTION) { > > - printk(KERN_WARNING "Node alignment %LuMB < min %LuMB, >

Re: [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-04 Thread Miguel Ojeda
On Thu, Jun 4, 2020 at 9:58 AM Thomas Gleixner wrote: > > but if we ever lose the 1 then the above will silently compile the code > within the IS_ENABLED() section out. Yeah, I believe `IS_ENABLED()` is only meant for Kconfig symbols, not macro defs in general. A better option would be `__is_defi

Re: [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-04 Thread Thomas Gleixner
Kees Cook writes: > -#ifdef NODE_NOT_IN_PAGE_FLAGS > - pfn_align = node_map_pfn_alignment(); > - if (pfn_align && pfn_align < PAGES_PER_SECTION) { > - printk(KERN_WARNING "Node alignment %LuMB < min %LuMB, > rejecting NUMA config\n", > -PFN_PHYS(pfn_align)

[PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage

2020-06-03 Thread Kees Cook
Using uninitialized_var() is dangerous as it papers over real bugs[1] (or can in the future), and suppresses unrelated compiler warnings (e.g. "unused variable"). If the compiler thinks it is uninitialized, either simply initialize the variable or make compiler changes. As a precursor to removing[2