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: <CAHmME9pGwyZKu=9yCben-V30hR+zEjb9iZGWr5_RAE-uXt_Ofw@mail.gmail.com>
Date:   Fri, 11 Feb 2022 01:42:56 +0100
From:   "Jason A. Donenfeld" <Jason@...c4.com>
To:     Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Linux Crypto Mailing List <linux-crypto@...r.kernel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        "Theodore Ts'o" <tytso@....edu>,
        Sultan Alsawaf <sultan@...neltoast.com>,
        Jonathan Neuschäfer <j.neuschaefer@....net>,
        Eric Biggers <ebiggers@...nel.org>
Subject: Re: [PATCH v4 2/2] random: defer fast pool mixing to worker

Hi Sebastian,

On Thu, Feb 10, 2022 at 7:04 PM Sebastian Andrzej Siewior
<bigeasy@...utronix.de> wrote:
> So.
> - CPU1 schedules a worker
> - CPU1 goes offline before the gets on the CPU.
> - The worker runs CPU2
> - CPU2 is back online
> - and now
>    CPU1                                         CPU2
>    new_count = ++fast_pool->count;
>     reg = fast_pool->count (FAST_POOL_MIX_INFLIGHT | 64)
>     incl reg (FAST_POOL_MIX_INFLIGHT | 65)
>                                                 WRITE_ONCE(fast_pool->count, 0);
>     fast_pool->count = reg ((FAST_POOL_MIX_INFLIGHT | 65)
>
> So we lost the WRITE_ONCE(, 0), FAST_POOL_MIX_INFLIGHT is still set and
> worker is not scheduled. Not easy to trigger, not by an ordinary user.
> Just wanted to mention…

Thanks for pointing this out. I'll actually fix this using atomics,
and fix another minor issue at the same time the same way, and move to
making sure the worker is running on the right CPU like we originally
discussed. I'm going to send that as an additional patch so that we
can narrow in on the issue there. It's a little bit involved but not
too bad. I'll have that for you shortly.

> crng_fast_load() does spin_trylock_irqsave() in hardirq context. It does
> not produce any warning on RT but is still wrong IMHO:
> If we just could move this, too.
> I don't know how timing critical this is but the first backtrace from
> crng_fast_load() came (to my surprise) from hwrng_fillfn() (a kthread)
> and added 64bytes in one go.

I'll look into seeing if I can do it. On my first pass a few days ago,
it seemed a bit too tricky, but I'll revisit after this part here
settles. Thanks for your benchmarks, by the way. That's useful.

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ