Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3594824ybi; Mon, 27 May 2019 02:42:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqcpgOJbQ03ASeGeZcowpI8jGzeSjeqzuMnsh9MobgIqUcueMx46ID4JMFrKFUOrw5cTnC X-Received: by 2002:a17:90a:7184:: with SMTP id i4mr30509590pjk.49.1558950166700; Mon, 27 May 2019 02:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558950166; cv=none; d=google.com; s=arc-20160816; b=xq10J8mFmwR9utbOpPe8fnQ3SkIHV1EPb2GT164st71tXe2QQzmfO/6Y2XqBGFGoor NS5Mrl2iXGKyffzVWmtRX2dvoQL+XfIPqulU6yE+Fbl18qrWwzjKiInc9C4132uc0E6y zNhq0soUxFazEgV+K3epHXHaw6x0Sj+Dg8GkUuhL8CbRM5VCmEm2R3eX612GULoDouwO nSBVzJr2eYggsUOpGtgtZJkELiwC++IRkwbFUocQMYMaN+Pwp1zjgoNCeJbvVHJOHj0Z DTwJ4HOuS8HowkKqX9Utz08oDIUISQA6vH2vLfR7wiaavpXrhMoPBUyO1C218qyrnEZP OeuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=kUYBmaC1hTxexFFih++Di2QrumXCyFj5FtWmkV5WbtE=; b=a0kHOzok+OkeZRY5sn/ickLQ2r7mFox0xC+l/J8GxhWyiKNT29FZkPOJfgMyILy47A awYi/ovbvTZbew1JO3HLU6jXb5/xNMejuX+PSk9zcMV4+2l6AnREBq5NxnuHmdwiP7cr k9IuniU8x0fwIQvw6Qzc388u5M549MRrLmK0WFBKtuJtmfNQtTkkvhpXghC/g5iZhinw WWPvhmLFa46/FVVVhuBGzejgHYp7JYSImZNFsj+tTElj2Z1EHh6D0AbwaSoekOEnoE65 Hwt6TBzcLmgl1PmiDDlN6yNRdg4L6ASkCgHzYsHLbOs93GuqViVb4aVcOYGvXik/5C8F xmKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si16096176pjq.94.2019.05.27.02.42.31; Mon, 27 May 2019 02:42:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbfE0JkS (ORCPT + 99 others); Mon, 27 May 2019 05:40:18 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39720 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725991AbfE0JkS (ORCPT ); Mon, 27 May 2019 05:40:18 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3ECA3419BF0B28FDFABB; Mon, 27 May 2019 17:40:16 +0800 (CST) Received: from SZX1000472652.huawei.com (100.100.247.164) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Mon, 27 May 2019 17:40:05 +0800 From: Yongliang Gao To: , , , , , , , CC: , , , , , Subject: [PATCH] arm: fix using smp_processor_id() in preemptible context Date: Mon, 27 May 2019 17:39:39 +0800 Message-ID: <1558949979-129251-1-git-send-email-gaoyongliang@huawei.com> X-Mailer: git-send-email 1.8.5.6 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [100.100.247.164] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org harden_branch_predictor() call smp_processor_id() in preemptible context, this would cause a bug messages. The bug messages is as follows: BUG: using smp_processor_id() in preemptible [00000000] code: syz-executor0/17992 caller is harden_branch_predictor arch/arm/include/asm/system_misc.h:27 [inline] caller is __do_user_fault+0x34/0x114 arch/arm/mm/fault.c:200 CPU: 1 PID: 17992 Comm: syz-executor0 Tainted: G O 4.4.176 #1 Hardware name: Hisilicon A9 [] (unwind_backtrace) from [] (show_stack+0x18/0x1c) [] (show_stack) from [] (dump_stack+0xc8/0x118) [] (dump_stack) from [] (check_preemption_disabled+0xf4/0x138) [] (check_preemption_disabled) from [] (__do_user_fault+0x34/0x114) [] (__do_user_fault) from [] (do_page_fault+0x3b4/0x3d8) [] (do_page_fault) from [] (do_DataAbort+0x58/0xf8) [] (do_DataAbort) from [] (__dabt_usr+0x40/0x60) Reported-by: Jingwen Qiu Signed-off-by: Yongliang Gao Cc: --- arch/arm/include/asm/system_misc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h index 66f6a3a..4a55cfb 100644 --- a/arch/arm/include/asm/system_misc.h +++ b/arch/arm/include/asm/system_misc.h @@ -22,9 +22,10 @@ static inline void harden_branch_predictor(void) { harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn, - smp_processor_id()); + get_cpu()); if (fn) fn(); + put_cpu(); } #else #define harden_branch_predictor() do { } while (0) -- 1.8.5.6