From patchwork Fri May 4 04:15:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 10379817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D0E460159 for ; Fri, 4 May 2018 04:16:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A81729317 for ; Fri, 4 May 2018 04:16:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E9B02931A; Fri, 4 May 2018 04:16:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 46BEE29317 for ; Fri, 4 May 2018 04:16:14 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=p5xNYUftV9Nmwb7RGWwJIhebdluzwJeDXSpWsopl8B4=; b=YyQsP0Iz3kBeTm +ukm+Lo3dlqe2amvA0fmCGljC6FjoUUntflPCKVp6fq02ODPeiglT3P/jjOYl9rfli86DDTVRpmh/ JUgb3zMzLXqc86tnQwEbs+RBZUHkNsUmdsWoP9clAGGnVp0EHsHQ+sMeedCd89Ybd4j7tbgprVZRn Sbso5N4lw0zhoWRqrszrV62t98LPnj+seGJCi4xHc69uunBsRG7y5Ci7enJLgKlXyvxOKlz/JhpWZ 036procx5oZO7y9qtoZzZKhL3jTAzwRi7/JufYmNI//WFc38Qsy4BSNq8HF5t6sfpaNcv8CwiySHz +qLWBoztIjQuEKDX+LKA==; 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 1fES8W-0007wH-Jf; Fri, 04 May 2018 04:16:00 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fES87-0007db-5x for linux-arm-kernel@lists.infradead.org; Fri, 04 May 2018 04:15:37 +0000 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D75C721716; Fri, 4 May 2018 04:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1525407324; bh=bI444yK8Gkf7JPZG5qJeqFqQF5wDQqj71NUPvNFQxOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HEjBZ0eE9rN+GVnMjlnk0313ninVMFz9LFRkDbSGtPZjcCd1e5TAZARTqO0Tzad/ tdKK8eayUi0wdDa66Z8szIqyZuLPU4WR3xhNKLJb/7QOuuKjKH9JZVZwxa2/wTnkjp ciP/Q9TteMBRPvf+M5VtO/o1qEmtk3zkTXWrQ/Ws= From: Masami Hiramatsu To: Russell King Subject: [BUGFIX PATCH v3 1/4] arm: kprobes: Fix to use get_kprobe_ctlblk after irq-disabed Date: Fri, 4 May 2018 13:15:01 +0900 Message-Id: <152540730083.29650.15621737261480060241.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <152540727123.29650.13679359124038587629.stgit@devbox> References: <152540727123.29650.13679359124038587629.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180503_211535_293355_B7EF0242 X-CRM114-Status: GOOD ( 12.37 ) 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: Jon Medhurst , Wang Nan , Will Deacon , linux-kernel@vger.kernel.org, stable@vger.kernel.org, mhiramat@kernel.org, linux-arm-kernel@lists.infradead.org, David Long Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Since get_kprobe_ctlblk() uses smp_processor_id() to access per-cpu variable, it hits smp_processor_id sanity check as below. [ 7.006928] BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1 [ 7.007859] caller is debug_smp_processor_id+0x20/0x24 [ 7.008438] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.16.0-rc1-00192-g4eb17253e4b5 #1 [ 7.008890] Hardware name: Generic DT based system [ 7.009917] [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [ 7.010473] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 7.010990] [] (dump_stack) from [] (check_preemption_disabled+0x138/0x13c) [ 7.011592] [] (check_preemption_disabled) from [] (debug_smp_processor_id+0x20/0x24) [ 7.012214] [] (debug_smp_processor_id) from [] (optimized_callback+0x2c/0xe4) [ 7.013077] [] (optimized_callback) from [] (0xbf0021b0) To fix this issue, call get_kprobe_ctlblk() right after irq-disabled since that disables preemption. Fixes: 0dc016dbd820 ("ARM: kprobes: enable OPTPROBES for ARM 32") Signed-off-by: Masami Hiramatsu Cc: stable@vger.kernel.org --- arch/arm/probes/kprobes/opt-arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/probes/kprobes/opt-arm.c b/arch/arm/probes/kprobes/opt-arm.c index bcdecc25461b..ddc5a82eb10d 100644 --- a/arch/arm/probes/kprobes/opt-arm.c +++ b/arch/arm/probes/kprobes/opt-arm.c @@ -165,13 +165,14 @@ optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs) { unsigned long flags; struct kprobe *p = &op->kp; - struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); + struct kprobe_ctlblk *kcb; /* Save skipped registers */ regs->ARM_pc = (unsigned long)op->kp.addr; regs->ARM_ORIG_r0 = ~0UL; local_irq_save(flags); + kcb = get_kprobe_ctlblk(); if (kprobe_running()) { kprobes_inc_nmissed_count(&op->kp);