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]
Message-ID: <CAEXW_YSdXWcM_WO8FNNAs_sy=d=dwd7Ox9Aayucu9hgJ9BLhHQ@mail.gmail.com>
Date:   Wed, 15 Feb 2023 09:59:22 -0500
From:   Joel Fernandes <joel@...lfernandes.org>
To:     Zqiang <qiang1.zhang@...el.com>
Cc:     mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
        paulmck@...nel.org, frederic@...nel.org, rcu@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] sched/isolation: Fix illegal CPU value by
 housekeeping_any_cpu() return

On Thu, Feb 9, 2023 at 6:55 PM Zqiang <qiang1.zhang@...el.com> wrote:
>
> For kernels built with CONFIG_NO_HZ_FULL=y, running the following tests:
>
[...]
> This commit therefore add checks for cpumask_any_and() return values
> in housekeeping_any_cpu(), if cpumask_any_and() returns an illegal CPU
> value, the housekeeping_any_cpu() will return current CPU number.
>
> Signed-off-by: Zqiang <qiang1.zhang@...el.com>
> ---
>  kernel/sched/isolation.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index 373d42c707bc..534397ab7a36 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -46,7 +46,11 @@ int housekeeping_any_cpu(enum hk_type type)
>                         if (cpu < nr_cpu_ids)
>                                 return cpu;
>
> -                       return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
> +                       cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
> +                       if (cpu >= nr_cpu_ids)
> +                               return smp_processor_id();
> +                       else
> +                               return cpu;

Nit: no need of "else", simply:

return (cpu >= nr_cpuids ? smp_processor_id() : cpu);

or

if (cpu >= nr_cpu_ids)
   return smp_processor_id();
return cpu;

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ