Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Documentation/x86: Fix PR_SET_SPECULATION_CTRL error codes

If you force-disable mitigations on the kernel cmdline, for SPEC_STORE_BYPASS
this ends up with the prctl returning -ENXIO, but contrary to the current docs
for the other controls it returns -EPERM. Fix that.

Note that this return value should probably be considered a bug. But, making
the behaviour consistent with the current docs seems more likely to break
existing users than help anyone out in practice, so just "fix" it by
specifying it as correct.

Since this is getting more wordy and confusing, also be more explicit about
"control is not possible" be mentioning the boot configuration, to better
distinguish this case conceptually from the FORCE_DISABLE failure mode.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20251111-b4-prctl-docs-2-v2-1-bc9d14ec9662@google.com

authored by

Brendan Jackman and committed by
Borislav Petkov (AMD)
4992ed78 f8f9c1f4

+8 -4
+8 -4
Documentation/userspace-api/spec_ctrl.rst
··· 81 81 ERANGE arg3 is incorrect, i.e. it's neither PR_SPEC_ENABLE nor 82 82 PR_SPEC_DISABLE nor PR_SPEC_FORCE_DISABLE. 83 83 84 - ENXIO Control of the selected speculation misfeature is not possible. 85 - See PR_GET_SPECULATION_CTRL. 84 + ENXIO For PR_SPEC_STORE_BYPASS: control of the selected speculation misfeature 85 + is not possible via prctl, because of the system's boot configuration. 86 86 87 - EPERM Speculation was disabled with PR_SPEC_FORCE_DISABLE and caller 88 - tried to enable it again. 87 + EPERM Speculation was disabled with PR_SPEC_FORCE_DISABLE and caller tried to 88 + enable it again. 89 + 90 + EPERM For PR_SPEC_L1D_FLUSH and PR_SPEC_INDIRECT_BRANCH: control of the 91 + mitigation is not possible because of the system's boot configuration. 92 + 89 93 ======= ================================================================= 90 94 91 95 Speculation misfeature controls