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: <CAHk-=wjxAk=PQBX4OvscNfGKfc+M8iKmNd6D39wOZzXV0k729w@mail.gmail.com>
Date:   Sat, 21 Oct 2023 11:08:31 -0700
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Vasily Gorbik <gor@...ux.ibm.com>,
        Andy Shevchenko <andriy.shevchenko@...el.com>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Kees Cook <keescook@...omium.org>
Cc:     Heiko Carstens <hca@...ux.ibm.com>,
        Alexander Gordeev <agordeev@...ux.ibm.com>,
        linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org
Subject: Re: [GIT PULL] s390 fixes for 6.6-rc7

Just re-quoting my suggestion here and adding Andy and Dmitry, who did
the original bitmap_alloc() helper interfaces a few years ago.

Also adding Kees in case he has any hardening suggestions, since this
is about (incorrect) overflow handling.

Kees: see my rant about mindlessly doing overflow handling in the wrong place in

   https://lore.kernel.org/all/CAHk-=wgTUz1bdY6zvsN4ED0arCLE8Sb==1GH8d0sjm5bu7zesQ@mail.gmail.com/

in case you or somebody has a better idea for BITS_TO_LONG handling
than just "you need to check for zero before and after".

             Linus

On Sat, 21 Oct 2023 at 10:56, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> If you *do* want to add proper overflow handling, you'd need to either
> fix BITS_TO_LONGS() some way (which is actually non-trivial since it
> needs to be able to stay a constant and only use the argument once),
> or you do something like
>
>         if (!bits)
>                 return ZERO_SIZE_PTR;
>         longs = BITS_TO_LONG(bits);
>         if (!longs)
>                 return NULL;
>         return vzalloc(longs * sizeof(long));
>
> and I'd suggest maybe we should
>
>  (a) do the above checking in our bitmap_alloc() routines
>
>  (b) also change our bitmap_alloc() routines to take 'size_t' instead
> of 'unsigned int' bit counts
>
>  (c) and finally, add that vzalloc() case, but simply using
>
>         kvmalloc_array(n, size, flags | __GFP_ZERO);
>
> instead.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ