lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 3 Aug 2022 11:42:11 +0200
From:   Ingo Molnar <mingo@...nel.org>
To:     Siddh Raman Pant <code@...dh.me>
Cc:     x86 <x86@...nel.org>, Dave Hansen <dave.hansen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        linux-kernel-mentees 
        <linux-kernel-mentees@...ts.linuxfoundation.org>
Subject: Re: [PATCH] x86/numa: Use cpumask_available instead of hardcoded
 NULL check


* Siddh Raman Pant <code@...dh.me> wrote:

> On Wed, 03 Aug 2022 14:38:19 +0530  Ingo Molnar <mingo@...nel.org> wrote:
> > 
> > * Siddh Raman Pant <code@...dh.me> wrote:
> > > There is no reason why allmodconfig would trigger the warning, [...]
> > 
> > Well, unless I'm misreading your changelog, all the warning needs to 
> > trigger is CONFIG_CPUMASK_OFFSTACK=y.
> > 
> > > as it has CONFIG_CPUMASK_OFFSTACK=y, but the warning is because of the 
> > > other case.
> > 
> > What 'other case'? I've re-read the discussion and don't see it, but maybe 
> > I'm a bit daft this morning ...
>  
> No, the warning is happening because CONFIG_CPUMASK_OFFSTACK is not set.

Oh. So I was daft, as suspected. ;-)

And I can confirm that while gcc-11 doesn't trigger the warning, gcc-12 
does:

  $ make ARCH=x86_64 CC=gcc-11 arch/x86/mm/numa.o
    CC      arch/x86/mm/numa.o
  $

  $ rm -f arch/x86/mm/numa.o
  $
  $ make ARCH=x86_64 CC=gcc-12 arch/x86/mm/numa.o

    CC      arch/x86/mm/numa.o
  arch/x86/mm/numa.c: In function ‘cpumask_of_node’:
  arch/x86/mm/numa.c:916:39: error: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Werror=address]
    916 |         if (node_to_cpumask_map[node] == NULL) {


> [...] This is because in that case cpumask_var_t type is not a pointer, 
> and thus the var can never be NULL, which leads gcc to warn us when 
> comparing with NULL.
> 
> The chain of events are like:
> 
>         #ifdef CONFIG_CPUMASK_OFFSTACK
>                 typedef struct cpumask *cpumask_var_t;
>         #else
>                 typedef struct cpumask cpumask_var_t[1];
>         endif
> 
>         cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
>         ...
>         if (node_to_cpumask_map[node] == NULL) {
> 
> 
> The fix works because:
> 
>         #ifdef CONFIG_CPUMASK_OFFSTACK
>                 static inline bool cpumask_available(cpumask_var_t mask)
>                 {
>                         return mask != NULL;
>                 }
>         #else
>                 static inline bool cpumask_available(cpumask_var_t mask)
>                 {
>                         return true;
>                 }
>         endif
> 
> 
> The conditional definitions, as pointed out earlier, can be seen from line 700
> of include/linux/cpumask.h file.

Yeah - and I agree with your fix - will apply it.

Thanks for your patience :-)

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ