From patchwork Mon Aug 24 23:58:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 7067241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9365E9F358 for ; Tue, 25 Aug 2015 00:01:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EA4C207DE for ; Tue, 25 Aug 2015 00:01:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A3BD207DB for ; Tue, 25 Aug 2015 00:01:57 +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 1ZU1eF-0005q2-Rz; Mon, 24 Aug 2015 23:59:31 +0000 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZU1eC-0005lr-QB for linux-arm-kernel@lists.infradead.org; Mon, 24 Aug 2015 23:59:29 +0000 Received: by pacti10 with SMTP id ti10so34997605pac.0 for ; Mon, 24 Aug 2015 16:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=UzvfwTEbhWtfPWHfv7+eXrgOp3furgnkhe8wuBQTGJQ=; b=erzarehpt7Mrk8CEbYQ9uPUw3L5Dc1sf8j37qPhyIIT4PrdM5ShBLO5dZis1QsNiKo 3zvq/KNPuHExA5Z7zgclosuw2PZb4rhyhmZVjgRDbhsB4FTFbA4xSB8e76+3J1wA/EYX JHrGD5XYmChekA53d6ZszQil2WpmE5k9bUgfI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UzvfwTEbhWtfPWHfv7+eXrgOp3furgnkhe8wuBQTGJQ=; b=gX/GKGgCNkEUjEOI9FliBbjG3nXs5KlnKRuL/IoHj9Z3Cxhbow2Q58amyrfqVGw/fK M4HuKSDVhi/gPBBwPSZXDkr7wa3qxsmYPAJZcaGzP9m7HWV0LhBWsJQlNudU3Slu1ysP PGxDA6Nd2P233WHgINm9SPca2wl76GT5w7EKMfYm0QNfhwwPHkpIRHZIFMQupUN/ctFZ bJSFxx4ZOlGcjuVY2ZkTvtipVNGIWGUiO06p/+zFMvQv3s9KEDYQscR8sIfvxdmCvKbI ugZTiq5kXnq2IOSof5XTf1tBiBQuU1YLOQv0ezhyqrH1Fw2Ufq+hxK/vMtilhNHPWTPs VS1Q== X-Gm-Message-State: ALoCoQnNEN9jxomUu5Tw3ZaCFuE+mTGX0RWpdL4BLCB8vK/hCfXiCbgAmF+sQK2BI6w0asKYBxnY X-Received: by 10.68.68.166 with SMTP id x6mr50026863pbt.101.1440460747017; Mon, 24 Aug 2015 16:59:07 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id c12sm18695321pdk.47.2015.08.24.16.59.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Aug 2015 16:59:06 -0700 (PDT) From: Douglas Anderson To: Kees Cook , Nicolas Pitre Subject: [PATCH] ARM: probes: Don't stop the machine if we're in the debugger Date: Mon, 24 Aug 2015 16:58:59 -0700 Message-Id: <1440460739-19522-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.5.0.457.gab17608 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150824_165928_981066_18950D36 X-CRM114-Status: GOOD ( 13.68 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tixy@linaro.org, wangnan0@huawei.com, linux@arm.linux.org.uk, linux-kernel@vger.kernel.org, Douglas Anderson , Aapo Vienamo , rabin@rab.in, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 If we're in kgdb then the machine is already stopped. Trying to stop it again will cause us to try to sleep, which is not allowed while in kgdb. To avoid this problem, only stop the machine when we're not in kgdb. Reported-by: Aapo Vienamo Suggested-by: Kees Cook Signed-off-by: Douglas Anderson --- arch/arm/kernel/patch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 2.5.0.457.gab17608 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c index 69bda1a..abf30ec 100644 --- a/arch/arm/kernel/patch.c +++ b/arch/arm/kernel/patch.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -124,6 +125,9 @@ void __kprobes patch_text(void *addr, unsigned int insn) .insn = insn, }; - stop_machine(patch_text_stop_machine, &patch, NULL); + /* Stop machine before patching; but not if in the debugger */ + if (unlikely(in_dbg_master())) + patch_text_stop_machine(&patch); + else + stop_machine(patch_text_stop_machine, &patch, NULL); } --