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: <Y43yaS1ybCCG6szm@zx2c4.com>
Date:   Mon, 5 Dec 2022 14:30:17 +0100
From:   "Jason A. Donenfeld" <Jason@...c4.com>
To:     Aurelien Jarno <aurelien@...el32.net>
Cc:     Olivia Mackall <olivia@...enic.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Heiko Stuebner <heiko@...ech.de>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Lin Jinhan <troy.lin@...k-chips.com>,
        "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
        <linux-crypto@...r.kernel.org>,
        "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
        <devicetree@...r.kernel.org>,
        "moderated list:ARM/Rockchip SoC support" 
        <linux-arm-kernel@...ts.infradead.org>,
        "open list:ARM/Rockchip SoC support" 
        <linux-rockchip@...ts.infradead.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/3] hwrng: add Rockchip SoC hwrng driver

On Mon, Dec 05, 2022 at 02:13:45PM +0100, Jason A. Donenfeld wrote:
> If your intention is "90%", this should be 921 or 922, because the
> quality knob is out of 1024, not 1000.
> 
> Herbert - this seems like a fairly common pitfall I've seen all over the
> place. It might be worth making a mental memo to reject or ask questions
> about numbers that seem "too round", when you look at these sorts of
> patches.

Or alternatively we could introduce a cheesy macro like:

   #define HWRNG_PERCENTAGE(p) ((p) * 1024 / 100)

and then enforce that everyone use that. But that's a bit wacky too, in
the sense of - why is anybody using a non-obvious percentage in the first
place. Like if you see "512" (or better, "1024 / 2"), okay fine, it's a
device that guarantees 50%, which seems like a common enough physical
thing. But if we see "HWRNG_PERCENTAGE(90)", the first question is why?
What causes that?  Seems very weird. And it's probably wrong.

But if it *is* right, that deserves a big comment with explanation,
where the calculation for that "921" literal can be explained in full,
or, better, evaluated as a constant expression in terms of hardware
constants -- something like
HW_CLOCKRATE/FROBNICATOR_INTENSITY*1024/TURBOENCABULATION_MODE_WEIGHT,
and then it all makes sense.

So maybe rather than a macro or accepting barebones "921" values, if the
value isn't 1024 (0), then it needs a comment + an expression computing
the value.

Seem reasonable?

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ