From patchwork Mon Jan 5 12:32:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 5567931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EB340BF6C3 for ; Mon, 5 Jan 2015 12:40:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26C2720172 for ; Mon, 5 Jan 2015 12:40:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E51720166 for ; Mon, 5 Jan 2015 12:40:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y86vY-0001Lx-1r; Mon, 05 Jan 2015 12:38:32 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y86vE-0000uc-GB for linux-arm-kernel@lists.infradead.org; Mon, 05 Jan 2015 12:38:13 +0000 Received: from 172.24.2.119 (EHLO lggeml425-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AZP33614; Mon, 05 Jan 2015 20:37:27 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml425-hub.china.huawei.com (10.72.61.35) with Microsoft SMTP Server id 14.3.158.1; Mon, 5 Jan 2015 20:37:17 +0800 From: Wang Nan To: , , Subject: [PATCH] kprobes: bugfix: force unoptimize when disable kprobes. Date: Mon, 5 Jan 2015 20:32:20 +0800 Message-ID: <1420461140-27153-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.50F2CDBD.0090, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: c5b0f7242290f3cd7460b973d5ddb2d9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150105_043812_860713_BB270726 X-CRM114-Status: UNSURE ( 7.64 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) Cc: lizefan@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Original code failed to disarm the probed instruction after echo 0 > /sys/kernel/debug/kprobes/enabled if OPTPROBE is enabled. This is caused by a piece of logically inconsistent code: unoptimize_kprobe(p, false); if (!kprobe_queued(p)) { ... } unoptimize_kprobe() with 'force' == false queues p onto unoptimizing_list, so following kprobe_queued() check always fail unless another core schedules optimizer and does the unoptimization very soon. This logic causes arch_disarm_kprobe() failed to get execute, lefts a breakpoint at the probed address, instead of restoring it. This patch uses force unoptimize instead. Signed-off-by: Wang Nan --- kernel/kprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index b185464..9fbe0c3 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -869,7 +869,7 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt) { struct kprobe *_p; - unoptimize_kprobe(p, false); /* Try to unoptimize */ + unoptimize_kprobe(p, true); /* Try to unoptimize */ if (!kprobe_queued(p)) { arch_disarm_kprobe(p);