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:   Tue, 1 Nov 2022 12:54:59 +0100
From:   "Jason A. Donenfeld" <Jason@...c4.com>
To:     Catalin Marinas <catalin.marinas@....com>
Cc:     linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Will Deacon <will@...nel.org>,
        Ard Biesheuvel <ardb@...nel.org>,
        Jean-Philippe Brucker <jean-philippe@...aro.org>
Subject: Re: [PATCH v3] random: remove early archrandom abstraction

Hi Catalin,

On Tue, Nov 1, 2022 at 12:39 PM Catalin Marinas <catalin.marinas@....com> wrote:
> > +static __always_inline bool __cpu_has_rng(void)
> > +{
> > +     if (!system_capabilities_finalized() && early_boot_irqs_disabled)
> > +             return __early_cpu_has_rndr();
> > +     return cpus_have_const_cap(ARM64_HAS_RNG);
> > +}
>
> I'm not sure about using early_boot_irqs_disabled, it is described as a
> debug helper.

Not sure that part matters much?

> It's also set to 'false' before
> system_capabilities_finalized() (once the full SMP is enabled).

Right, so there's still a "hole", where we'll ball back to
cpus_have_final_cap(), which might return false. In practice I don't
think this matters much. But it's still not perfect.

>
> Would something like this work:
>
>         if (system_capabilities_finalized())
>                 return cpus_have_final_cap(ARM64_HAS_RNG);
>         if (!preemptible())
>                 return __early_cpu_has_rndr();
>         return false;

That'd be fine. Of course that introduces a different sort of "hole",
when it's called from preemptable context. But again, that doesn't
matter in practice. So I'll send you a v4 doing that for you to ack.

I'm going to structure it like this, though:

static __always_inline bool __cpu_has_rng(void)
{
        if (!system_capabilities_finalized() && !preemptible())
                return __early_cpu_has_rndr();
        return cpus_have_const_cap(ARM64_HAS_RNG);
}

Because cpus_have_const_cap() itself has a fallback mode before
system_capabilities_finalized() is true, where it checks a big
bitmask. So that seems like a better fallback than `false`, in case it
happens to be true.

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ