Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756214AbbHYWGG (ORCPT ); Tue, 25 Aug 2015 18:06:06 -0400 Received: from mail-vk0-f53.google.com ([209.85.213.53]:34846 "EHLO mail-vk0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752641AbbHYWGE (ORCPT ); Tue, 25 Aug 2015 18:06:04 -0400 MIME-Version: 1.0 In-Reply-To: References: <55C230C7.2000909@nvidia.com> Date: Tue, 25 Aug 2015 15:06:02 -0700 X-Google-Sender-Auth: -SPSo-4e_Lmy8uXdOrRZ1UXnxoc Message-ID: Subject: Re: [BUG] arm: kgdb: patch_text() in kgdb_arch_set_breakpoint() may sleep From: Doug Anderson To: Kees Cook Cc: Aapo Vienamo , Nicolas Pitre , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1611 Lines: 40 Hi, On Mon, Aug 24, 2015 at 4:56 PM, Doug Anderson wrote: >> Perhaps we need to test if we're already atomic in patch_text, and >> only call stop_machine if we need to? >> >> Untested (and likely mangled by gmail): >> >> diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c >> index 69bda1a5707e..855696bfe072 100644 >> --- a/arch/arm/kernel/patch.c >> +++ b/arch/arm/kernel/patch.c >> @@ -124,5 +124,8 @@ void __kprobes patch_text(void *addr, unsigned int insn) >> .insn = insn, >> }; >> >> - stop_machine(patch_text_stop_machine, &patch, NULL); >> + if (unlikely(in_atomic_preempt_off())) >> + patch_text_stop_machine(&patch); >> + else >> + stop_machine(patch_text_stop_machine, &patch, NULL); > > Ah, right. We're already stopped, so just not stopping again seems > reasonable. I think I'd rather just use in_dbg_master() as the test > since that's a case where I _know_ all the CPUs are stopped. Doesn't > in_atomic_preempt_off() just check if preemption is off for this > single CPU? > > Anyway, I'll throw a patch up now. It fixes it for me. :) In case anyone happens upon this thread, the patch I originally put up is at . ...I've since spun it to -Doug -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/