From patchwork Wed Jun 22 06:49:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 12890251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1FB28C43334 for ; Wed, 22 Jun 2022 06:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:From:Cc:To:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=9sZaiHTR7zStsy3IVi/U2IGKUBCf3kFi6pkxo/5/M7g=; b=cSiC3++ehVTyTy CZP9MyL4UQPKLI66vwvw8KDF0gHQ7GB6pp3lseJ86xm/SlF5UolEKuDuLkQPaEO6U21bC8kNok3co cy1kJe32+2Xx/+qwNlzHW1BZZ8lVNS1WKbyaR/PMoOM28haiiB0nI684nkHUb9K8hwPdJN/yq/X0j e7nh1AfWXTJAz/hnZvbbH6lST0f0lC5Gmm4oprn11zr42cY+gUXOaCa8A7FZQf9es+bKX2DpVNXDu XSwFNOlFylLBKOfuggYDt3i4xeBbiKkDIVyout6FfMWpS9S6ljX7a+NrOMJzjycTAwSMBlUCc86DY DltK+criIrBOgn8oZOGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3uBV-008w38-OV; Wed, 22 Jun 2022 06:49:53 +0000 Received: from www262.sakura.ne.jp ([202.181.97.72]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3uBR-008vvm-HE for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2022 06:49:51 +0000 Received: from fsav412.sakura.ne.jp (fsav412.sakura.ne.jp [133.242.250.111]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 25M6nNKG065902; Wed, 22 Jun 2022 15:49:23 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav412.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav412.sakura.ne.jp); Wed, 22 Jun 2022 15:49:23 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav412.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 25M6nMAZ065894 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Wed, 22 Jun 2022 15:49:23 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <795c9463-452e-bf64-1cc0-c318ccecb1da@I-love.SAKURA.ne.jp> Date: Wed, 22 Jun 2022 15:49:21 +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 Content-Language: en-US To: Russell King , Tony Lindgren Cc: LKML , Linux ARM From: Tetsuo Handa Subject: [PATCH] ARM: spectre-v2: fix smp_processor_id() warning X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220621_234949_848380_A06282AE X-CRM114-Status: UNSURE ( 8.19 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org syzbot complains smp_processor_id() from harden_branch_predictor() from page fault path [1]. Explicitly disable preemption and use raw_smp_processor_id(). Link: https://syzkaller.appspot.com/bug?extid=a7ee43e564223f195c84 [1] Reported-by: syzbot Fixes: f5fe12b1eaee220c ("ARM: spectre-v2: harden user aborts in kernel space") Signed-off-by: Tetsuo Handa --- This patch is completely untested. arch/arm/include/asm/system_misc.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h index 98b37340376b..a92446769acd 100644 --- a/arch/arm/include/asm/system_misc.h +++ b/arch/arm/include/asm/system_misc.h @@ -20,8 +20,11 @@ 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()); + harden_branch_predictor_fn_t fn; + + preempt_disable_notrace(); + fn = per_cpu(harden_branch_predictor_fn, raw_smp_processor_id()); + preempt_enable_no_resched_notrace(); if (fn) fn(); }