From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754894AbbHYATa (ORCPT ); Mon, 24 Aug 2015 20:19:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:33646 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbbHYAT3 (ORCPT ); Mon, 24 Aug 2015 20:19:29 -0400 Message-ID: <55DBB48E.7040508@codeaurora.org> Date: Mon, 24 Aug 2015 17:19:26 -0700 From: Stephen Boyd User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Douglas Anderson CC: Kees Cook , Nicolas Pitre , tixy@linaro.org, wangnan0@huawei.com, linux@arm.linux.org.uk, linux-kernel@vger.kernel.org, Aapo Vienamo , rabin@rab.in, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] ARM: probes: Don't stop the machine if we're in the debugger References: <1440460739-19522-1-git-send-email-dianders@chromium.org> In-Reply-To: <1440460739-19522-1-git-send-email-dianders@chromium.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/24/2015 04:58 PM, Douglas Anderson wrote: > 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 > --- Can you add the backtrace? > arch/arm/kernel/patch.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > 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); > } Perhaps it would be better to add a different function for the kgdb call site? Then it's explicit what's going on without us having to figure out when in_dbg_master() is true. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project