Re: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation

Pawan Gupta
2025-01-09T05:22:45Z

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.

Other issue is below print in retbleed_update_mitigation() will dereference
a NULL pointer:

pr_info("%s\n", retbleed_strings[retbleed_mitigation]);