From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A5DC28CBF for ; Mon, 27 May 2019 09:40:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 995182175B for ; Mon, 27 May 2019 09:40:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfE0JkT (ORCPT ); Mon, 27 May 2019 05:40:19 -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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6807BC07542 for ; Mon, 27 May 2019 09:40:35 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 390EC21721 for ; Mon, 27 May 2019 09:40:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="V4f8mPzR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 390EC21721 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From: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=D5IKzvux9iszbmYGdyimULhqs15qdNHzXVuhHX8sfJ4=; b=V4f8mPzR/2EveA qkBjRAi92w5k1h9fJqqm+EAp/k/C6Vq6gKRjAoEOz9ePXzrju87IP6w7Th5B8Bg+gfbwQDCFh/S6Q yuZtb2r6BIgFk7xCSVOLp4rZW5hDyzC9rT2kyTbyz8wfPqJ5AsptjjleKMO++kQ4am9/vhDGplUFl w11/HKCU7cbYNhAfbacOlm9R3nifzXTlr0QV8z4xqeChHaEH5u5X3EalZLqJEC2A1mS5YHZI3wql+ +AozJd+T3re8QYaYBHMEJtEcJY9Wd53HD+BX2jRuzFLdLEzChkmIi45s0NPJROsGc8mIs4hrIVVa2 Yr7jIhAj6zfeJxMzGgQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVC7K-0003rq-Sn; Mon, 27 May 2019 09:40:30 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVC7H-0003r7-KU for linux-arm-kernel@lists.infradead.org; Mon, 27 May 2019 09:40:29 +0000 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: , , , , , , , 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 X-Originating-IP: [100.100.247.164] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190527_024027_906665_5E51B5EC X-CRM114-Status: UNSURE ( 9.85 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shiwenlu@huawei.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, zengweilin@huawei.com, nixiaoming@huawei.com, chenjie6@huawei.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel