From patchwork Mon Feb 13 19:40:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 56524 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2538285wrn; Mon, 13 Feb 2023 11:45:25 -0800 (PST) X-Google-Smtp-Source: AK7set9GIsW+ZjJUS928/V6FBoXWgcFnevgSofPc0G3Oar0biuk95EYM8YPh6knP6gqOnW+6Hf8M X-Received: by 2002:a17:906:db0b:b0:8ae:80d5:7385 with SMTP id xj11-20020a170906db0b00b008ae80d57385mr25430614ejb.10.1676317524868; Mon, 13 Feb 2023 11:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676317524; cv=none; d=google.com; s=arc-20160816; b=h1JPhkSxkgkP96j8DTbVoYRftErWX+DovYFiBu1TlHtmg+Ia+y5Xe8gljp9gB63TOO mwzk/a7MBTM+YRVnRjcPklLZjqPjQEsHMCP8eWOrdjXHQz+KFFTgaI3hPLRE5sZNsBwz mPC6tq9DrWBPL/Kc45+LCrW6cSsdNPBIgeZcvHnhFXDcVtgTOndDNXJfxpoiqbu9hCYP NYu+gaOciDbuGdyjhqUWWbNa8KJi/H8xM+H/UaIjb9pgf0TeziPt6dEilVSMngb0Dnpq gpppxSHP9N7x2YSQGIYGKM6MMew9Bgya1942iH/htbiU7wlLI4LbpNyC/0/+0yPUBEVe bZ6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=I0P3cKwwzq7UwdBcPOvJrRfC3Q6kvdGRMBw77mYRrlM=; b=MxRUbUOYx5bUWlIbNXSA0ABTOzgbnylaAecpH0zzCcOTAZvNK9xSn+N9ijdn3VGuc5 90IkJ4sKfNblSFeW7uGpRNyBQ0gGE7bt9sAyvWZLWatUu4uRqE3A2vzhJF4e/Kiif9Hb Xb66sOj/Pg4Ur/shTqLwNOWQ5iqEjKlRaOD52Q91hv0DPsVwhBQyP5RGQBzFpcZQFfKM icKQyTQl8Xcr2gCsGWWEYKfow+B9H25ucKtzONGqpcytqSuJyo+vZiAOtcwj1haidBSq pbGHEMNLTtTok0DbamG1rioaJOLxWRoxUsfLXMdhVSVkL/DxvwJKKLCLg/QSpc3B8oyg yMhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Zcu/xBhU"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a170906534900b008add06590d6si16854722ejo.700.2023.02.13.11.45.02; Mon, 13 Feb 2023 11:45:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Zcu/xBhU"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231467AbjBMTla (ORCPT + 99 others); Mon, 13 Feb 2023 14:41:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231298AbjBMTlF (ORCPT ); Mon, 13 Feb 2023 14:41:05 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A447F20D13; Mon, 13 Feb 2023 11:40:49 -0800 (PST) Date: Mon, 13 Feb 2023 19:40:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1676317248; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I0P3cKwwzq7UwdBcPOvJrRfC3Q6kvdGRMBw77mYRrlM=; b=Zcu/xBhUaRgtXBgkuz3N8RlBdS/PtSh2EVrZgp9VhK6Tavk2+IejcXLa1xqyIIWvefZf2l rcuQCi2ZZgFyNLH28+R3cvcIuJQ8S7cMfGRBqVTLLfiePO8ov+dXED4/jecWK1xX5HNBIR kXsusjl7JBFa+meoB5/hfqDk9NgFzFw8LSZJVwCp2drGSgI08JnW+yejRzdExufYhZSf6d 0GkFLMDyQqxvGf2gX6tpo7hj0/LOgrWvENAHl4sHb7qax9KxSxuvT8MZIHiJubdJIsQO8o pZ/a4UQR8JsJdOA8bjSFQqv3+uDMIhSya2H/5oENNJukS+wUHWRBmEbNEfDsoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1676317248; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I0P3cKwwzq7UwdBcPOvJrRfC3Q6kvdGRMBw77mYRrlM=; b=go1a7xAo4YDy0kf7182Zd00x33e7zBm0lqpilNbs+b5kwHC5LxcIJ2nUAstHnKa5sI63TN rI8nB0BRJ4ofF5DQ== From: "irqchip-bot for Johan Hovold" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-next] irqdomain: Fix disassociation race Cc: stable@vger.kernel.org, #@tip-bot2.tec.linutronix.de, 4.13@tip-bot2.tec.linutronix.de, "Hsin-Yi Wang" , "Mark-PK Tsai" , Johan Hovold , Marc Zyngier , tglx@linutronix.de In-Reply-To: <20230213104302.17307-3-johan+linaro@kernel.org> References: <20230213104302.17307-3-johan+linaro@kernel.org> MIME-Version: 1.0 Message-ID: <167631724735.4906.17602457971577144696.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757712345154617793?= X-GMAIL-MSGID: =?utf-8?q?1757746324718453553?= The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: 3f883c38f5628f46b30bccf090faec054088e262 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/3f883c38f5628f46b30bccf090faec054088e262 Author: Johan Hovold AuthorDate: Mon, 13 Feb 2023 11:42:44 +01:00 Committer: Marc Zyngier CommitterDate: Mon, 13 Feb 2023 19:31:24 irqdomain: Fix disassociation race The global irq_domain_mutex is held when mapping interrupts from non-hierarchical domains but currently not when disposing them. This specifically means that updates of the domain mapcount is racy (currently only used for statistics in debugfs). Make sure to hold the global irq_domain_mutex also when disposing mappings from non-hierarchical domains. Fixes: 9dc6be3d4193 ("genirq/irqdomain: Add map counter") Cc: stable@vger.kernel.org # 4.13 Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20230213104302.17307-3-johan+linaro@kernel.org --- kernel/irq/irqdomain.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 6661de1..f77549a 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -538,6 +538,9 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) return; hwirq = irq_data->hwirq; + + mutex_lock(&irq_domain_mutex); + irq_set_status_flags(irq, IRQ_NOREQUEST); /* remove chip and handler */ @@ -557,6 +560,8 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) /* Clear reverse map for this hwirq */ irq_domain_clear_mapping(domain, hwirq); + + mutex_unlock(&irq_domain_mutex); } static int irq_domain_associate_locked(struct irq_domain *domain, unsigned int virq,