From patchwork Mon Feb 20 21:37:13 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: 59678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1524740wrn; Mon, 20 Feb 2023 13:39:53 -0800 (PST) X-Google-Smtp-Source: AK7set9WMkuEBULchRXGYQY6MNVHQTVoqlhri0sRrogtSxGOQUpZi/NMK4fC6FZNu0Nm39EIrkXi X-Received: by 2002:a17:90b:4f87:b0:234:91a2:e07c with SMTP id qe7-20020a17090b4f8700b0023491a2e07cmr3119569pjb.31.1676929192936; Mon, 20 Feb 2023 13:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676929192; cv=none; d=google.com; s=arc-20160816; b=AKorDl1kh5rk6YlxLS0l8WsqORuUF+gzbhiO8hZYFX4r+pWE7wSI+e7LyxoYSnHil+ H6APtftE0woDK3LQGF3/pxFradPGnPRABWwYrpt72MfNCTyPc7lId9w0krBk9ba+3/aq V8qtrQY2RH1USdFjG+ZN5jqc5QhDbV8DUOH30flJQtSFHJxqeruCG9J1sVIncfI/AKpN KCYi+CNw3Kbzo2aXC6+0wgIpfzkSJgjds3FwFR8b22375owqRUAHOJ9kGtMv/6CqzqtR 0LDUECmyj7uUVNr4IuQJfuO6HvVdmgTC5jK0BfX7l9mXUZsaup+5N5MjVYLYNhjmyUI8 Hc9w== 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=OUkh5Ko3jhevc1Bk0P+SZ5C68Sj3b1dGZJOtZcbce38=; b=KxAlEaacfzbrVzmDEQlHoZdXf0khR8/Za5+efIx1jQSPPfzG6B5yEuGK2w+gxxwB63 ogVG5kZ8NYlLpQJQOILzp2bXGTq8d48aWfLKVAj6RbuD+EIZGjKkBWM4RBx3KCcY/GyQ bYppbcAo24eeckq0g4BOrrw/q6aM2yyAc2uwS+FtRehNLWdKJ6mBX87pnqhO/rsA6+lt LbNZX050cd6LH25d5oHsqAE4lbYAiRTUuGofTMVqxMoFy96cdNIBnJPZdXeVREq8vtWj aq8HzzzjJfQr8QZje5eDF8M0q6JaK1+GL7jYlmg947jLfBrivnuOX5Lgbro8O8GQqZ57 sAWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0CNtf7kc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=4xN8exoT; 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 f17-20020a17090ac29100b00233d0451109si15892231pjt.16.2023.02.20.13.39.40; Mon, 20 Feb 2023 13:39:52 -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=0CNtf7kc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=4xN8exoT; 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 S231785AbjBTVhT (ORCPT + 99 others); Mon, 20 Feb 2023 16:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232258AbjBTVhQ (ORCPT ); Mon, 20 Feb 2023 16:37:16 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20C2212A2; Mon, 20 Feb 2023 13:37:15 -0800 (PST) Date: Mon, 20 Feb 2023 21:37:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1676929034; 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=OUkh5Ko3jhevc1Bk0P+SZ5C68Sj3b1dGZJOtZcbce38=; b=0CNtf7kcqFkcV9pWdxoJNHAKuu1BeQ/YK/XLZQgDHkbNqnSU79B9P0STpA+qtBktIaWmuh y9Ucm07H/GhPXyAOt/Fa7OkHpQdfwts3rUJlURtxuY6bI1yoaqK9X7E1FQDeEmN6GLLy4t BxpQF+Yxe7Vg7NtdOvHh0uPMSADiLk9orEbDjoGNFqWntB5sPsOJkSBcAN0P3hnwXWBZky aAiqzdSa1HXAcIxRYQl6AhX2eqtfoc1GWBcEfgvznf2H6RHx3LY8UbLX/ElR9dOgmvuf+U Q6kMV3hKA3+zPQs3a61gSByVVeSh5+oAKjwym6xXqy6MI22kZ9owe1hFwa4ZKQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1676929034; 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=OUkh5Ko3jhevc1Bk0P+SZ5C68Sj3b1dGZJOtZcbce38=; b=4xN8exoTrPvE1IPo7Xe37RWmAbNOwHsWXLIAR4a153ZZFVK+SVqEwOW5eDjBrg5XDnOt6M N/zx3VeXq9mPUGAg== From: "tip-bot2 for Marc Zyngier" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/urgent] genirq/msi: Take the per-device MSI lock before validating the control structure Cc: "Russell King (Oracle)" , Marc Zyngier , Thomas Gleixner , "Russell King (Oracle)" , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <8E@shell.armlinux.org.uk> References: <8E@shell.armlinux.org.uk> MIME-Version: 1.0 Message-ID: <167692903325.387.6855102455566331681.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?1758387704942679934?= X-GMAIL-MSGID: =?utf-8?q?1758387704942679934?= The following commit has been merged into the irq/urgent branch of tip: Commit-ID: 0af2795f936f1ea1f9f1497447145dfcc7ed2823 Gitweb: https://git.kernel.org/tip/0af2795f936f1ea1f9f1497447145dfcc7ed2823 Author: Marc Zyngier AuthorDate: Mon, 20 Feb 2023 19:01:01 Committer: Thomas Gleixner CommitterDate: Mon, 20 Feb 2023 22:29:54 +01:00 genirq/msi: Take the per-device MSI lock before validating the control structure Calling msi_ctrl_valid() ultimately results in calling msi_get_device_domain(), which requires holding the device MSI lock. However, in msi_domain_populate_irqs() the lock is taken right after having called msi_ctrl_valid(), which is just a tad too late. Take the lock before invoking msi_ctrl_valid(). Fixes: 40742716f294 ("genirq/msi: Make msi_add_simple_msi_descs() device domain aware") Reported-by: "Russell King (Oracle)" Signed-off-by: Marc Zyngier Signed-off-by: Thomas Gleixner Tested-by: Russell King (Oracle) Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/Y/Opu6ETe3ZzZ/8E@shell.armlinux.org.uk Link: https://lore.kernel.org/r/20230220190101.314446-1-maz@kernel.org --- kernel/irq/msi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 783a3e6..13d9649 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1084,10 +1084,13 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev, struct xarray *xa; int ret, virq; - if (!msi_ctrl_valid(dev, &ctrl)) - return -EINVAL; - msi_lock_descs(dev); + + if (!msi_ctrl_valid(dev, &ctrl)) { + ret = -EINVAL; + goto unlock; + } + ret = msi_domain_add_simple_msi_descs(dev, &ctrl); if (ret) goto unlock;