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] [day] [month] [year] [list]
Date: Fri, 19 Jan 2024 09:48:47 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Yury Norov <yury.norov@...il.com>
Cc: linux-kernel@...r.kernel.org, Yoshinori Sato <ysato@...rs.sourceforge.jp>, 
	Rich Felker <dalias@...c.org>, John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>, linux-sh@...r.kernel.org, 
	Jan Kara <jack@...e.cz>, Mirsad Todorovac <mirsad.todorovac@....unizg.hr>, 
	Matthew Wilcox <willy@...radead.org>, Rasmus Villemoes <linux@...musvillemoes.dk>, 
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, 
	Maxim Kuvyrkov <maxim.kuvyrkov@...aro.org>, Alexey Klimov <klimov.linux@...il.com>, 
	Bart Van Assche <bvanassche@....org>, Sergey Shtylyov <s.shtylyov@....ru>
Subject: Re: [PATCH v2 35/35] sh: mach-x3proto: rework ilsel_enable()

On Sun, Dec 3, 2023 at 8:34 PM Yury Norov <yury.norov@...il.com> wrote:
> Fix opencoded find_and_set_bit(), which also suppresses potential
> KCSAN warning.
>
> CC: John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>
> Signed-off-by: Yury Norov <yury.norov@...il.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@...der.be>

> --- a/arch/sh/boards/mach-x3proto/ilsel.c
> +++ b/arch/sh/boards/mach-x3proto/ilsel.c
> @@ -99,8 +99,8 @@ int ilsel_enable(ilsel_source_t set)
>         }
>
>         do {
> -               bit = find_first_zero_bit(&ilsel_level_map, ILSEL_LEVELS);
> -       } while (test_and_set_bit(bit, &ilsel_level_map));
> +               bit = find_and_set_bit(&ilsel_level_map, ILSEL_LEVELS);
> +       } while (bit >= ILSEL_LEVELS);
>
>         __ilsel_enable(set, bit);

BTW, I don't think the old code worked as intended: the first time no
free bit is found, bit would have been ILSEL_LEVELS, and
test_and_set_bit() would have returned false, thus terminating the loop,
and continuing with an out-of-range bit value?  Hence to work correctly,
bit ILSEL_LEVELS of ilsel_level_map should have been initialized to one?
Or am I missing something?

The new code does not have that issue.

Anyway, this should probably never happen in real life.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68korg

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ