Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1669945

Re: [PATCH] random: silence compiler warnings and fix race

From "Jason A. Donenfeld" <Jason@zx2c4.com>
Newsgroups linux.kernel
Subject Re: [PATCH] random: silence compiler warnings and fix race
Date 2017-06-19 23:00 +0200
Message-ID <tUbWa-7E3-13@gated-at.bofh.it> (permalink)
References <tSmj0-Qa-5@gated-at.bofh.it> <tSpgR-2GV-13@gated-at.bofh.it> <tT0zL-1hl-9@gated-at.bofh.it> <tT9Wp-7Ft-1@gated-at.bofh.it> <tTZBD-89S-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jun 19, 2017 at 9:45 AM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> ehm. You sure? I simply delayed the lock-dropping _after_ the state
> variable was been modified. So it was basically what your patch did
> except it was unlocked later…

Yes, I'm sure. You moved the call to invalidate_batched_entropy() to
be after the assignment of crng_init. However, the call to
invalidate_batched_entropy() must be made _before_ the assignment of
crng_init.

>> > Are use about that? I am not sure that the gcc will inline "crng_init"
>> > read twice. It is not a local variable. READ_ONCE() is usually used
>> > where gcc could cache a memory access but you do not want this. But hey!
>> > If someone knows better I am here to learn.
>>
>> The whole purpose is that I _want_ it to cache the memory access so
>> that it is _not_ inlined. So, based on your understanding, it does
>> exactly what I intended it to do. The reason is that I'd like to avoid
>> a lock imbalance, which could happen if the read is inlined.
>
> So it was good as it was which means you can drop that READ_ONCE().

Except READ_ONCE ensures that the compiler will never inline it, so it
actually needs to stay.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 00/13] Unseeded In-Kernel Randomness Fixes "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 13/13] random: warn when kernel uses unseeded randomness "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 06/13] iscsi: ensure RNG is seeded before use "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 05/13] crypto/rng: ensure that the RNG is ready before using "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 11/13] net/route: use get_random_int for random counter "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 10/13] net/neighbor: use get_random_u32 for 32-bit hash random "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 08/13] cifs: use get_random_u32 for 32-bit lock random "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 12/13] bluetooth/smp: ensure RNG is properly seeded before ECDH use "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 02/13] random: add synchronous API for the urandom pool "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 01/13] random: invalidate batched entropy after crng init "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
    Re: [PATCH v5 01/13] random: invalidate batched entropy after crng  init Sebastian Andrzej Siewior <sebastian@breakpoint.cc> - 2017-06-14 21:40 +0200
      Re: [PATCH v5 01/13] random: invalidate batched entropy after crng init "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-15 00:40 +0200
        Re: [PATCH v5 01/13] random: invalidate batched entropy after crng  init Sebastian Andrzej Siewior <sebastian@breakpoint.cc> - 2017-06-16 10:40 +0200
          Re: [PATCH v5 01/13] random: invalidate batched entropy after crng init "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-16 14:20 +0200
            Re: [PATCH v5 01/13] random: invalidate batched entropy after crng  init Sebastian Andrzej Siewior <sebastian@breakpoint.cc> - 2017-06-16 16:40 +0200
      [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-15 00:50 +0200
        Re: [PATCH] random: silence compiler warnings and fix race Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-06-16 16:40 +0200
          Re: [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-17 02:40 +0200
            Re: [PATCH] random: silence compiler warnings and fix race Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-06-19 09:50 +0200
              Re: [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-19 23:00 +0200
                Re: [PATCH] random: silence compiler warnings and fix race Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-06-20 08:50 +0200
        Re: [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-19 23:00 +0200
          Re: [PATCH] random: silence compiler warnings and fix race Theodore Ts'o <tytso@mit.edu> - 2017-06-20 08:10 +0200
            Re: [kernel-hardening] Re: [PATCH] random: silence compiler warnings  and fix race Joel Stanley <joel@jms.id.au> - 2017-06-20 08:30 +0200
            Re: [kernel-hardening] Re: [PATCH] random: silence compiler warnings and fix race Michael Ellerman <mpe@ellerman.id.au> - 2017-06-20 09:10 +0200
            Re: [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-20 10:20 +0200
              Re: [PATCH] random: silence compiler warnings and fix race Jeffrey Walton <noloader@gmail.com> - 2017-06-20 10:40 +0200
                Re: [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-20 11:00 +0200
                Re: [PATCH] random: silence compiler warnings and fix race Jeffrey Walton <noloader@gmail.com> - 2017-06-20 11:50 +0200
                Re: [kernel-hardening] Re: [PATCH] random: silence compiler warnings  and fix race Sandy Harris <sandyinchina@gmail.com> - 2017-06-20 20:00 +0200
                Re: [kernel-hardening] Re: [PATCH] random: silence compiler warnings  and fix race Kees Cook <keescook@chromium.org> - 2017-06-20 20:20 +0200
                Re: [kernel-hardening] Re: [PATCH] random: silence compiler warnings  and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-20 22:10 +0200
                Re: [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-20 11:50 +0200
                Re: [PATCH] random: silence compiler warnings and fix race Theodore Ts'o <tytso@mit.edu> - 2017-06-21 01:40 +0200
                Re: [PATCH] random: silence compiler warnings and fix race "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-21 02:00 +0200
                [PATCH] random: warn when kernel uses unseeded randomness "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-21 02:10 +0200
                Re: [PATCH] random: warn when kernel uses unseeded randomness Kees Cook <keescook@chromium.org> - 2017-06-21 02:20 +0200
                Re: [kernel-hardening] [PATCH] random: warn when kernel uses unseeded randomness Michael Ellerman <mpe@ellerman.id.au> - 2017-06-21 08:10 +0200
                Re: [kernel-hardening] [PATCH] random: warn when kernel uses  unseeded randomness Theodore Ts'o <tytso@mit.edu> - 2017-06-21 22:40 +0200
                Re: [kernel-hardening] [PATCH] random: warn when kernel uses unseeded randomness "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-22 02:10 +0200
                Re: [PATCH] random: silence compiler warnings and fix race Jeffrey Walton <noloader@gmail.com> - 2017-06-22 02:00 +0200
                Re: [PATCH] random: silence compiler warnings and fix race Theodore Ts'o <tytso@mit.edu> - 2017-06-20 12:00 +0200
  [PATCH v5 03/13] random: add get_random_{bytes,u32,u64,int,long,once}_wait family "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200
  [PATCH v5 04/13] security/keys: ensure RNG is seeded before use "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-06-08 01:30 +0200

csiph-web