From patchwork Wed May 24 08:15:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9745355 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 F1549601C2 for ; Wed, 24 May 2017 08:28:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF6CF28420 for ; Wed, 24 May 2017 08:28:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D238E2891F; Wed, 24 May 2017 08:28:13 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 6124628420 for ; Wed, 24 May 2017 08:28:13 +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:Subject:To:From :Date:Message-Id:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=yPWlyH5SACpdpzXJv3x0AmZYPBSHjhX6WZ86WK9TGBI=; b=j5vmwx+CzfsR+G eYFHgeREo9RQ5zf2YEwpCRGGRZyCKJHvbzK37XW+C88SHFMh++7dfrp7LEEgITnBRGqv5CIlXOKAO ZMg3YXSGlmF0XndP3oLc0ntTQ2St5fZPllSCWA5MA98nlpL+Yyt9StYEbWjEvFk5Ii/Z1mwI1CeHY SKYZwYcq06CYOFF9TIQrpUBopSYY0XeisqWPgwIgsDZXcKnt8SEx/XBrrh2WanYQC2pd0vPNNv8TT TMsRZnNNraknIv4bGy/TuiS+qHrBjquHyCNMDvo5WefH8wBpFEAKjHFBho8v//p8jcYmFnwdxASvq V8oUOvYyUOa7SXd6RdRA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dDReO-0008BF-D1; Wed, 24 May 2017 08:28:12 +0000 Received: from galois.linutronix.de ([2a01:7a0:2:106d:700::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dDRdR-00074a-Lg for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2017 08:27:18 +0000 Received: from localhost ([127.0.0.1] helo=[127.0.1.1]) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1dDRca-0008Dc-4X; Wed, 24 May 2017 10:26:20 +0200 Message-Id: <20170524081549.275871311@linutronix.de> User-Agent: quilt/0.63-1 Date: Wed, 24 May 2017 10:15:38 +0200 From: Thomas Gleixner To: LKML Subject: [patch V3 27/32] arm: Prevent hotplug rwsem recursion References: <20170524081511.203800767@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=arm--Prevent-hotplug-rwsem-recursion.patch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170524_012714_294009_8E1D9E33 X-CRM114-Status: UNSURE ( 9.30 ) X-CRM114-Notice: Please train this message. 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: Peter Zijlstra , Sebastian Siewior , Russell King , Steven Rostedt , Paul McKenney , Ingo Molnar , linux-arm-kernel@lists.infradead.org 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 The text patching functions which are invoked from jump_label and kprobes code are protected against cpu hotplug at the call sites. Use stop_machine_cpuslocked() to avoid recursion on the cpu hotplug rwsem. stop_machine_cpuslocked() contains a lockdep assertion to catch any unprotected callers. Signed-off-by: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Cc: Russell King --- arch/arm/kernel/patch.c | 2 +- arch/arm/probes/kprobes/core.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/arch/arm/kernel/patch.c +++ b/arch/arm/kernel/patch.c @@ -124,5 +124,5 @@ void __kprobes patch_text(void *addr, un .insn = insn, }; - stop_machine(patch_text_stop_machine, &patch, NULL); + stop_machine_cpuslocked(patch_text_stop_machine, &patch, NULL); } --- a/arch/arm/probes/kprobes/core.c +++ b/arch/arm/probes/kprobes/core.c @@ -182,7 +182,8 @@ void __kprobes kprobes_remove_breakpoint .addr = addr, .insn = insn, }; - stop_machine(__kprobes_remove_breakpoint, &p, cpu_online_mask); + stop_machine_cpuslocked(__kprobes_remove_breakpoint, &p, + cpu_online_mask); } void __kprobes arch_disarm_kprobe(struct kprobe *p)