Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp81225iog; Thu, 23 Jun 2022 23:04:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vErDpxQzXXNFVj36VJguWbRUTJDgYRpXF8gfXj+CwhJjZBN2kHMjc76cTCyR9u2Ef/UEwA X-Received: by 2002:a63:6cc4:0:b0:408:b022:8222 with SMTP id h187-20020a636cc4000000b00408b0228222mr10497415pgc.435.1656050643817; Thu, 23 Jun 2022 23:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656050643; cv=none; d=google.com; s=arc-20160816; b=oEU+BGO/IXzqFy7Yr/gT1EutNqJ9bKUdCarewKwPnchqpywHR1d0MVcMkEXwhr+YAt /azZ9moes+kkv+GCFZXp7N3wRk+au3yCYYPmOd1V9r2E6JEYdJSGnJxwNLFKmFT0ELra nCMF22mFjPxV3wi6iH/P8BYc7lmae1U/81M+iAOclQL0xlCfmQCGN40dudw4m2QLa6eA aRjdRKzRGVnxpusV/4rSKYxdA/Zsvd7L1RNSbIa8ks+oRpcySnK0CU1mcG1WgIIBsXPG 3ugKniQ1x8wTXWUIQXdJC/jIGp4A8K3Iq2dlWfmfAPFa32Baha8JmR0SPaaybj0Y6Y+g 5flA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=MVI/FaieSIZ7x0KvbthqzWnkl19JiVZ8djFrCKfcOAw=; b=nNXBDu1NYqLIoffVI3KpsMxPLdMCA+9KqjlFAjgSsbH4G6FpJooWdAtI8lRrEPzWQX HvZv67bndnrGW4HX0Nk4K/UHAOGj9SF+Y8Gcmg4WCGMFLfsVw64Yy8zgD1aZ5Su9+wfe hjtvHPycF/mJ709eYAzMuGsUnFPTeYoV5K3lcgkHrQZ9szShYVR7VdT/fNvvIOfqntB5 r4a5USpNx8rZazg/+rcNuJDdqymxFzKCHFMeaO5dbNoSb0wJxLiS/5bi7dMPtUsyPmx9 ICf3YHISz1yI+dnh/WC1vgbXaS55cgQMMdWAD/ssCD4lASkspkLQx/E/ovctaM+Qf7Mu ESEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a17090332ca00b0016210da22e5si2078166plr.215.2022.06.23.23.03.51; Thu, 23 Jun 2022 23:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbiFXFke (ORCPT + 99 others); Fri, 24 Jun 2022 01:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiFXFkd (ORCPT ); Fri, 24 Jun 2022 01:40:33 -0400 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F91069988 for ; Thu, 23 Jun 2022 22:40:32 -0700 (PDT) Received: from fsav119.sakura.ne.jp (fsav119.sakura.ne.jp [27.133.134.246]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 25O5dwZE025105; Fri, 24 Jun 2022 14:39:58 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav119.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav119.sakura.ne.jp); Fri, 24 Jun 2022 14:39:58 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav119.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 25O5dv5b025098 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Fri, 24 Jun 2022 14:39:58 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Fri, 24 Jun 2022 14:39:56 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] ARM: spectre-v2: fix smp_processor_id() warning Content-Language: en-US From: Tetsuo Handa To: "Russell King (Oracle)" , Marc Zyngier Cc: Tony Lindgren , LKML , Linux ARM References: <795c9463-452e-bf64-1cc0-c318ccecb1da@I-love.SAKURA.ne.jp> <421c1ca9-f553-4c0a-d963-2fdeb270dbcc@I-love.SAKURA.ne.jp> In-Reply-To: <421c1ca9-f553-4c0a-d963-2fdeb270dbcc@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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