From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796352820; b=xkBG92m8cBWFMNje94xg2UjrQ5QNKpXkFCdWoPW6QX4MysvUgRjRyUwwsXl51MPdobWd SZBZYTzcxvGdlKT5+QsdCMKem2+OYmEIczLmB8vU3umRBr3GSTfXeRtysanHlo31Z61Q2 pjEhsyD3HnveBA9Gk4hOiLGQDC5MwpUH8qhoxdEl0d5GqMNzFJTpNTljjdtNzl6y/I4ZF GFZQLhmmNh+HjrSy5VdeUtwHyFdOSbWcGkCEq26oPoB8i+4JMG2HK6yUbSg0qINSFU60b 5cy/Gq7Zzm4RCR8UBEzWjl/OR40O7UxsjuzozRULGpdufXvMHiGIAqZQE1RsMLqxxhQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796352820; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=q+o5ENe5rGRd1yCRD4xdIcQnU+wZgobaFTkkP+IsfGg=; b=uk38sp9H11wSmZJutZPtcVzE/Ea7esevjeWB39h8B/1woAS9kzn3/2nj51FKSQmCRMfl LbUbCITObsv6xsatIJHCS/2U2UY3SzHvEcnqxaiQH2W29EsGgDDNoiH85ELe5p8B+ZimU jwGknawaaM1IjbPu2qldzuzL1Dp8/qFX3UFkLEWwebtp9D2netquvCCP9XkUBfinTwsZe VqneKzR5uKjSdEVA6qDna1AC3jQ4yvwy6IbrL8CTYQxuz3/NdCi/JBHE/CN/jmRRKAmtY y8CW3ieQ0Q2QlBKJeS03CI6w/5itNR5Rom/jfYYioKWOG2lUJmeS42z4uH9qIUSXFqA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Dd+IB1di; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D3B3606A322 for ; Fri, 4 Dec 2026 02:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Dd+IB1di Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796352819; b=OrzM/O66VGextSk41JBjd9RpxNBlrEmlbLlXT7vddzl+GtAhNXGLwcR3zaGB4k5x8SE7 ezBPI/RD9j+tHPmZXiEkAZ/YCqtLk+w8nYt2cXbjYOHBciwZOde7mjKv8oiv2oXhe7yiC 57xmI/BB7s/lY8XYj9WdqVTxSGAYh7SfrAbltH/AvfaBKxm4d48mDEgv1w4Kj3gWzxVpj KsY0/i+lZf1AEaQBuEA0pHkWadfVgidqfsilqIZw3XYUn0VpqmkWppSkSUZvnN0sWlzU6 vjDhyiaFSSCMZm0yAmZQYLdzSevXoqtkUWOJHRwG60aIwWijgTeHzGGT0Si8JOVbGOw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796352819; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=q+o5ENe5rGRd1yCRD4xdIcQnU+wZgobaFTkkP+IsfGg=; b=YW+ptmik1IBKu3WgchkTn3Le2AV8ncs+qGWH0IzF+MDtLIIWMIlVytnslzgfOqeae+CX G2c+/FGP220wLHnLrutsrAY/HjgKmYpO3qBWEtZhbn9fP+qfmCjIJ6KaKlUfJgs1D6dWS 7zOChaCDVPKxmS8GhZsg9HHR+SmMJvYRLtAuY89DaYNmp8L81gZG/3Y4cfaoFzGZ1Z8Fr tbR7tAkEKkcNIxVGi9yPUMZ2UTMTsoF4ag4pY8GBiq6PSC5/6yDkN78kIsodGMhNRa4PL Es/YgN7dZnfkQNqfUp93BDWd/6K4DbgX9ojFrkgoM7WzLefyUU6A6wkVoe06C4x0t9A== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 150141F000CE; Fri, 4 Dec 2026 02:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796352819; bh=q+o5ENe5rGRd1yCRD4xdIcQnU+wZgobaFTkkP+IsfGg=; h=From:Date:Subject:To:Cc:Reply-To; b=Dd+IB1diNBd+ZrqHejXh0g9pvfBNR8R80tvkLb5HgIg82HNAYXBnl9nRHFdVtpE00 KFcBpZ0I8iSVWZOtAzeLbyrMDccUB1Tsc05DZ1zwmbVXhLIRQoKdwfvxzLFiY3wrcI /gfe/WJNipN5f4d40o5+3mwkEXJjsHLXipGrfz03xdGvESAfqF4UWJQtSiHadB2zxc vh5OXDZmrv6JExrUiF5wlKkld/2FJ2ThMD8W5mstWZuGuk9FotmyG65akJA2MhIubj tShBziYflELECwcEAR3HBcsyVoMi0to333QCufollCQk6mAZoeoxJo8rSH1Gy+DU0j SdXlCE3b7F3Sg== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 675F0422C0; Fri, 4 Dec 2026 02:53:38 +0000 (UTC) From: Anh Nguyen Hoang via B4 Relay Date: Thu, 03 Dec 2026 20:53:38 -0600 Subject: [PATCH] ipmi:msghandler: Put the interface on the BMC changed retry X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261203-kbug-l1316-v1-1-233b33545491@gmail.com> X-B4-Tracking: v=1; b=H4sIADErEmsC/yXMQQ5AMBBA0as0s9akrShxFbGgHQxS0iIScXfF8 i3+vyCgJwxQsgs8HhRocREyYWCGxvXIyUaDEkpLJVI+tXvPZ5lKzXVnTKZtnqkihxisHjs6v1l V/w57O6LZ3gPc9wPLvNFtbgAAAA== X-Change-ID: 20261203-kbug-l1316-6fcc56d75287 To: Corey Minyard Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Anh Nguyen Hoang X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796352818; l=2284; i=anhnh.4work@gmail.com; s=20261127; h=from:subject:message-id; bh=sYDNo6HLMDgah4ncD9JmO4eOZ+JR96YwD1jraV8Bv3I=; b=aM/UQRLIVS5B5ESpIwng+/wkzGoGLIracgIdxwSHpK2GsJEtYhWka010JSSS6IYgIIL4/S5qC 9be6SyqfBggDj4xoSLOMWr2ZT5Ps8UGj9ywFJBON1WpNqCxoKAx/U0i X-Developer-Key: i=anhnh.4work@gmail.com; a=ed25519; pk=9NJ/0SKqaFZmt1/I5XY11TZSNY2ys6RWB3gvqzrLHmI= X-Endpoint-Received: by B4 Relay for anhnh.4work@gmail.com/20261127 with auth_id=1662 X-Original-From: Anh Nguyen Hoang Reply-To: anhnh.4work@gmail.com Content-Transfer-Encoding: 7bit From: Anh Nguyen Hoang When __bmc_get_device_id() is called without an interface, it takes a reference on the first interface of the BMC. If the BMC's device id or GUID has changed, it re-registers the BMC and jumps back to retry_bmc_lock without dropping that reference, so the interface is never freed. Drop the reference before retrying, as the other retry in this function does. Found by a static analysis tool. Fixes: b2cfd8ab4add ("ipmi: Rework device id and guid handling to catch changing BMCs") Signed-off-by: Anh Nguyen Hoang --- Runtime test: QEMU, x86_64 defconfig + IPMI_HANDLER + IPMI_SI + KPROBE_EVENTS, on next-20261202 (its ipmi_msghandler.c is the same as the one in ipmi for-next). A scripted BMC behind ipmi-bmc-extern changes its product id while the guest runs. A read of ipmi_bmc.0/product_id by uid 1000 then takes this retry. The interface is then removed through the ipmi_si hotmod parameter, with kprobes on ipmi_unregister_smi() and intf_free(). Before the patch: the refcount is 2 when entering ipmi_unregister_smi() and intf_free() is never called. After the patch: the refcount is 1 and intf_free() is called. Same result with two KCS interfaces on one BMC. With an unchanged BMC, both kernels free the interface. This patch was drafted with AI assistance (Claude, claude-fable-5-2). Testing: - Compile-tested on x86_64 (allmodconfig, W=1): drivers/char/ipmi/ipmi_msghandler.o; no new warnings. - checkpatch.pl --strict: no errors or warnings. --- drivers/char/ipmi/ipmi_msghandler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 52e95e1949b9..f80d16dce449 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -2770,6 +2770,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, * the next interface for the BMC. */ mutex_unlock(&intf->bmc_reg_mutex); + kref_put(&intf->refcount, intf_free); mutex_lock(&bmc->dyn_mutex); goto retry_bmc_lock; } --- base-commit: 551bbbed906516e04956e4de0896fb8c1317ea86 change-id: 20261203-kbug-l1316-6fcc56d75287 Best regards, -- Anh Nguyen Hoang