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: <20231015141147.qeczgcfnl73zcqao@treble>
Date:   Sun, 15 Oct 2023 07:11:47 -0700
From:   Josh Poimboeuf <jpoimboe@...nel.org>
To:     Ingo Molnar <mingo@...nel.org>
Cc:     Breno Leitao <leitao@...ian.org>, tglx@...utronix.de, bp@...en8.de,
        Ingo Molnar <mingo@...hat.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
        "H. Peter Anvin" <hpa@...or.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>, leit@...a.com,
        "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" 
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4] x86/bugs: Add a separate config for each mitigation

On Fri, Oct 13, 2023 at 12:50:59PM +0200, Ingo Molnar wrote:
> 
> * Josh Poimboeuf <jpoimboe@...nel.org> wrote:
> 
> > On Thu, Oct 12, 2023 at 08:51:24PM +0200, Ingo Molnar wrote:
> > > > Another way to avoid ifdeffery:
> > > > 
> > > > static enum retbleed_mitigation_cmd retbleed_cmd __ro_after_init =
> > > > 	IS_ENABLED(CONFIG_MITIGATION_RETBLEED) ? RETBLEED_CMD_AUTO : RETBLEED_CMD_OFF;
> > > 
> > > I think we could make it a simple:
> > > 
> > > 	static enum retbleed_mitigation_cmd retbleed_cmd __ro_after_init = IS_ENABLED(CONFIG_MITIGATION_RETBLEED);
> > > 
> > > Because RETBLEED_CMD_AUTO && RETBLEED_CMD_OFF maps naturally to 1 and 0. 
> > > Maybe add a comment to the enum to maintain this property in the future 
> > > too.
> > 
> > Hm, that both obfuscates the default and makes it fragile.  The fact
> > that it would need a comment to try to prevent breaking it in the future
> > is a clue that maybe we shouldn't do it ;-)
> 
> Can be enforced with BUILD_BUG_ON().

That replaces fragility with brittleness.  If we change a default then
we have to go rearrange the corresponding enum, and update the
BUILD_BUG_ONs.

More importantly, it's still less readable because the reader now has to
go read the enum values to cross-reference the hard-coded values of 0
and 1 with the enums which are used everywhere else.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ