RE: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation
From: Kaplan, David
Date: Thu Jan 09 2025 - 10:27:10 EST
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>
> Sent: Wednesday, January 8, 2025 11:23 PM
> To: Kaplan, David <David.Kaplan@xxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>; Borislav Petkov <bp@xxxxxxxxx>; Peter
> Zijlstra <peterz@xxxxxxxxxxxxx>; Josh Poimboeuf <jpoimboe@xxxxxxxxxx>; Ingo
> Molnar <mingo@xxxxxxxxxx>; Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>;
> x86@xxxxxxxxxx; H . Peter Anvin <hpa@xxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Wed, Jan 08, 2025 at 02:24:52PM -0600, David Kaplan wrote:
> [...]
> > @@ -1064,6 +1063,7 @@ enum spectre_v2_mitigation spectre_v2_enabled
> > __ro_after_init = SPECTRE_V2_NONE;
> >
> > enum retbleed_mitigation {
> > RETBLEED_MITIGATION_NONE,
> > + RETBLEED_MITIGATION_AUTO,
>
> This new enum ...
>
> > RETBLEED_MITIGATION_UNRET,
> > RETBLEED_MITIGATION_IBPB,
> > RETBLEED_MITIGATION_IBRS,
> > @@ -1071,14 +1071,6 @@ enum retbleed_mitigation {
> > RETBLEED_MITIGATION_STUFF,
> > };
> >
> > -enum retbleed_mitigation_cmd {
> > - RETBLEED_CMD_OFF,
> > - RETBLEED_CMD_AUTO,
> > - RETBLEED_CMD_UNRET,
> > - RETBLEED_CMD_IBPB,
> > - RETBLEED_CMD_STUFF,
> > -};
> > -
> > static const char * const retbleed_strings[] = {
> > [RETBLEED_MITIGATION_NONE] = "Vulnerable",
> > [RETBLEED_MITIGATION_UNRET] = "Mitigation: untrained return thunk",
>
> ... does not have a corresponding entry in the strings array. AUTO is the default,
> and it is possible that mitigation mode can stay AUTO throughout the retbleed
> mitigation selection depending on cmdline and CONFIGs. e.g.
> retbleed=stuff and spectre_v2=off.
The intent was never to allow AUTO to persist, it should always be turned into a real mitigation. However it looks like I did miss a case there, where if the mitigation is AUTO when retbleed_select_mitigation() is called, the bug should be mitigated but the vendor isn't AMD/Hygon, it wasn't being transformed.
I'll figure out how to fix this to match the existing functionality, thanks for pointing this out.
--David Kaplan
>
> Other issue is below print in retbleed_update_mitigation() will dereference a NULL
> pointer:
>
> pr_info("%s\n", retbleed_strings[retbleed_mitigation]);