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:   Mon, 30 Apr 2018 19:00:49 +0000
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Kees Cook <keescook@...omium.org>
Cc:     tcharding <me@...in.cc>, Steven Rostedt <rostedt@...dmis.org>,
        Anna-Maria Gleixner <anna-maria@...utronix.de>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: Hashed pointer issues

On Mon, Apr 30, 2018 at 11:38 AM Kees Cook <keescook@...omium.org> wrote:

> Something like this? (Untested.)

Looks workable.

> +       /* If we have hw RNG, start hashing immediately. */
> +       if (arch_has_random()) {
> +               get_random_bytes_arch(&ptr_key, sizeof(ptr_key));
> +               ptr_key_ready();
> +               return 0;
> +       }

Small tweak: you should check the return value of get_random_bytes_arch(),
because in theory it can fail.

Sadly, that's not actually how get_random_bytes_arch() really works - it
falls back on "get_random_bytes()" on failure instead, which is explicitly
against the whole point here.

So I think it would need some tweaking, with a new function entirely
(get_random_bytes_arch() with a failure return for "cannot fill buffer").

But that would be just a few more lines, because we could make the existing
get_random_bytes_arch() just use the failure-case thing.

So add a "get_hw_random_bytes()" that does that same loop in
get_random_bytes_arch(), but returns the number of bytes it filled in.

Then get_random_bytes_arch() turns into

     got = get_hw_random_bytes(p, nbytes);
     if (got < nbytes)
         get_random_bytes(p+got, nbytes-got);

and the initialize_ptr_random() use would be something like

     if (get_hw_random_bytes(&ptr_key, sizeof(ptr_key)) == sizeof(ptr_key)) {
         ptr_key_ready();
         return 0;
    }

Hmm?

Maybe we could call the "get_hw_random_bytes()" something like
"get_early_random_bytes()" and the "use HW for it" is purely an
implementation detail?

                Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ