Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 5bcedc5

Browse files
committed
powerpc/security: Fix Speculation_Store_Bypass reporting on Power10
Nageswara reported that /proc/self/status was showing "vulnerable" for the Speculation_Store_Bypass feature on Power10, eg: $ grep Speculation_Store_Bypass: /proc/self/status Speculation_Store_Bypass: vulnerable But at the same time the sysfs files, and lscpu, were showing "Not affected". This turns out to simply be a bug in the reporting of the Speculation_Store_Bypass, aka. PR_SPEC_STORE_BYPASS, case. When SEC_FTR_STF_BARRIER was added, so that firmware could communicate the vulnerability was not present, the code in ssb_prctl_get() was not updated to check the new flag. So add the check for SEC_FTR_STF_BARRIER being disabled. Rather than adding the new check to the existing if block and expanding the comment to cover both cases, rewrite the three cases to be separate so they can be commented separately for clarity. Fixes: 84ed26f ("powerpc/security: Add a security feature for STF barrier") Cc: [email protected] # v5.14+ Reported-by: Nageswara R Sastry <[email protected]> Tested-by: Nageswara R Sastry <[email protected]> Reviewed-by: Russell Currey <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 8bbe9fe commit 5bcedc5

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

arch/powerpc/kernel/security.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -364,26 +364,27 @@ ssize_t cpu_show_spec_store_bypass(struct device *dev, struct device_attribute *
364364

365365
static int ssb_prctl_get(struct task_struct *task)
366366
{
367+
/*
368+
* The STF_BARRIER feature is on by default, so if it's off that means
369+
* firmware has explicitly said the CPU is not vulnerable via either
370+
* the hypercall or device tree.
371+
*/
372+
if (!security_ftr_enabled(SEC_FTR_STF_BARRIER))
373+
return PR_SPEC_NOT_AFFECTED;
374+
375+
/*
376+
* If the system's CPU has no known barrier (see setup_stf_barrier())
377+
* then assume that the CPU is not vulnerable.
378+
*/
367379
if (stf_enabled_flush_types == STF_BARRIER_NONE)
368-
/*
369-
* We don't have an explicit signal from firmware that we're
370-
* vulnerable or not, we only have certain CPU revisions that
371-
* are known to be vulnerable.
372-
*
373-
* We assume that if we're on another CPU, where the barrier is
374-
* NONE, then we are not vulnerable.
375-
*/
376380
return PR_SPEC_NOT_AFFECTED;
377-
else
378-
/*
379-
* If we do have a barrier type then we are vulnerable. The
380-
* barrier is not a global or per-process mitigation, so the
381-
* only value we can report here is PR_SPEC_ENABLE, which
382-
* appears as "vulnerable" in /proc.
383-
*/
384-
return PR_SPEC_ENABLE;
385-
386-
return -EINVAL;
381+
382+
/*
383+
* Otherwise the CPU is vulnerable. The barrier is not a global or
384+
* per-process mitigation, so the only value that can be reported here
385+
* is PR_SPEC_ENABLE, which appears as "vulnerable" in /proc.
386+
*/
387+
return PR_SPEC_ENABLE;
387388
}
388389

389390
int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which)

0 commit comments

Comments
 (0)