lkml.org 
[lkml]   [2022]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH] ARM: spectre-v2: fix smp_processor_id() warning
From
On 2022/06/23 0:02, Tetsuo Handa wrote:
> On 2022/06/22 23:04, Russell King (Oracle) wrote:
>> Which makes me think... having the loud complaint from the kernel there
>> is actually a good thing, it makes people sit up and notice that
>> something is wrong.
>
> OK. Then, would you change the code not to emit "BUG:" message, for
> syzkaller stops testing upon encountering "BUG:" string?
>

Something like this?

arch/arm/include/asm/system_misc.h | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h
index 98b37340376b..09d5c2262165 100644
--- a/arch/arm/include/asm/system_misc.h
+++ b/arch/arm/include/asm/system_misc.h
@@ -20,10 +20,22 @@ typedef void (*harden_branch_predictor_fn_t)(void);
DECLARE_PER_CPU(harden_branch_predictor_fn_t, harden_branch_predictor_fn);
static inline void harden_branch_predictor(void)
{
- harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn,
- smp_processor_id());
+ static DEFINE_RATELIMIT_STATE(predictor_rs, 10 * HZ, 1);
+ const bool is_preemptible = preemptible();
+ harden_branch_predictor_fn_t fn;
+
+ if (unlikely(is_preemptible)) {
+ ratelimit_set_flags(&predictor_rs, RATELIMIT_MSG_ON_RELEASE);
+ if (__ratelimit(&predictor_rs))
+ pr_err("%s[%d] page fault with preemption enabled (exploit attempt?)\n",
+ current->comm, task_pid_nr(current));
+ preempt_disable_notrace();
+ }
+ fn = per_cpu(harden_branch_predictor_fn, raw_smp_processor_id());
if (fn)
fn();
+ if (unlikely(is_preemptible))
+ preempt_enable_no_resched_notrace();
}
#else
#define harden_branch_predictor() do { } while (0)
--
2.18.4
\
 
 \ /
  Last update: 2022-06-24 07:42    [W:0.079 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site