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]
Message-ID: <CANpmjNMzeU8GBkNr-_6Rq8+9CNW476DBMpck9oeFw-pE5J0beg@mail.gmail.com>
Date:   Mon, 23 Nov 2020 20:12:44 +0100
From:   Marco Elver <elver@...gle.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     "Paul E. McKenney" <paulmck@...nel.org>,
        Will Deacon <will@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Boqun Feng <boqun.feng@...il.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        kasan-dev <kasan-dev@...glegroups.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] kcsan: Avoid scheduler recursion by using
 non-instrumented preempt_{disable,enable}()

On Mon, 23 Nov 2020 at 17:08, Peter Zijlstra <peterz@...radead.org> wrote:
> On Mon, Nov 23, 2020 at 04:57:46PM +0100, Marco Elver wrote:
> > Let me know what you prefer.
> >
>
> > @@ -288,27 +288,19 @@ static u32 kcsan_prandom_u32_max(u32 ep_ro)
> >       u32 res;
> >
> >       /*
> > +      * Avoid recursion with scheduler by disabling KCSAN because
> > +      * preempt_enable_notrace() will still call into scheduler code.
> >        */
> > +     kcsan_disable_current();
> >       preempt_disable_notrace();
> >       state = raw_cpu_ptr(&kcsan_rand_state);
> >       res = prandom_u32_state(state);
> > +     preempt_enable_notrace();
> > +     kcsan_enable_current_nowarn();
> >
> >       return (u32)(((u64) res * ep_ro) >> 32);
> >  }
>
> This is much preferred over the other. The thing with _no_resched is that
> you can miss a preemption for an unbounded amount of time, which is bad.

Ah, I think this is rubbish, too. Because it might fix one problem,
but now I'm left with the problem that kcsan_prandom_u32_max() is
called for udelay() later and at that point we lose skip_count
randomness entirely.

I think relying on lib/random32.c already caused too many headaches,
so I'm tempted to just get rid of that dependency entirely. And
instead do the simplest possible thing, which might just be calling
get_cycles() (all we need is to introduce some non-determinism).

> The _only_ valid use of _no_resched is when there's a call to schedule()
> right after it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ