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-next>] [day] [month] [year] [list]
Date:   Tue, 30 Aug 2022 14:02:56 -0700
From:   Yury Norov <yury.norov@...il.com>
To:     kernel test robot <lkp@...el.com>, linux-kernel@...r.kernel.org
Cc:     kbuild-all@...ts.01.org, Vivek Goyal <vgoyal@...hat.com>,
        Yinghai Lu <yinghai@...nel.org>,
        "H. Peter Anvin" <hpa@...ux.intel.com>,
        Yury Norov <yury.norov@...il.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Valentin Schneider <vschneid@...hat.com>,
        Sander Vanheule <sander@...nheule.net>,
        Alexey Klimov <klimov.linux@...il.com>,
        Eric Biggers <ebiggers@...gle.com>
Subject: Re: [PATCH 4/4] lib/cpumask: add FORCE_NR_CPUS config option

+ Vivek Goyal <vgoyal@...hat.com>
+ Yinghai Lu <yinghai@...nel.org>
+ H. Peter Anvin <hpa@...ux.intel.com>

On Wed, Aug 31, 2022 at 02:33:41AM +0800, kernel test robot wrote:
> Hi Yury,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on tip/x86/core]
> [also build test WARNING on linus/master v6.0-rc3 next-20220830]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Yury-Norov/cpumask-cleanup-nr_cpu_ids-vs-nr_cpumask_bits-mess/20220830-010755
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git bc12b70f7d216b36bd87701349374a13e486f8eb
> config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20220831/202208310215.C2IzssKr-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@...el.com>
> 
> smatch warnings:
> arch/x86/kernel/apic/apic.c:2437 generic_processor_info() warn: always true condition '(num_processors >= (1) - 1) => (0-u32max >= 0)'

This is the code that woke up the smatch:
  /*
   * If boot cpu has not been detected yet, then only allow upto
   * nr_cpu_ids - 1 processors and keep one slot free for boot cpu
   */
  if (!boot_cpu_detected && num_processors >= nr_cpu_ids - 1 &&
      apicid != boot_cpu_physical_apicid) {
          int thiscpu = max + disabled_cpus - 1;

          pr_warn("APIC: NR_CPUS/possible_cpus limit of %i almost"
                  " reached. Keeping one slot for boot cpu."
                  "  Processor %d/0x%x ignored.\n", max, thiscpu, apicid);

          disabled_cpus++;
          return -ENODEV;
  }

It has been added in a patch 14cb6dcf0a023f597 ("x86, boot: Wait for
boot cpu to show up if nr_cpus limit is about to hit")

My patch adds an option FORCE_NR_CPUS that makes nr_cpu_ids a compile-time
defined.

Hence, the num_processors >= nr_cpus - 1,
may become: num_processors >= 0, if NR_CPUS == 1.

So the plain straightforward fix would be:

    if (!boot_cpu_detected &&
 #if (NR_CPUS > 1)
        num_processors >= nr_cpu_ids - 1 &&
 #endif
        apicid != boot_cpu_physical_apicid) { ... }

However, I have a feeling that all the logic above is not needed at
all on UP machines. If that's true, the '#if NR_CPUS > 1' should
protect the whole condition, or even bigger piece of the
generic_processor_info().

Guys, could you please comment on that?

Thanks,
Yury

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ