Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC8C32580F2 for ; Thu, 4 Sep 2025 15:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757000029; cv=none; b=FsFGiKDhQyDCaUx7IgVNTN/4ouMJrskesKq7niUoQu72VqrFs343p8vBQdsyFJNbCscRky9H2AUw34Hb0PWUBaXZbhxvKvOI6pm/8O7ZoxAIAahtK7sb5kg+c3m0NQhlZnVJTNhFiIdMZDzFzmTawn3WKdvSCX+GWPl36M34cyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757000029; c=relaxed/simple; bh=lTZqQHKY5f6b0Z6ndwsO52NnSth+sQTGRN7Fb8avZeQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tRJa1O8Do9npOnBzfwJdxEumTbvkGwO3fn9JNUBXJCrX9yO4EJNv17AC4ebPOj7RjhdAQhW9IiayHYulkuxy2kQRGIbekDbKjRg3TRSnwS1gGljUTlNTTHYL8Pu/9hN4xuGFHgRAmQ1LsWpxX2vbHRDsPFRWTqURjCsyfL4ysLw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GqVJ9zFb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GqVJ9zFb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B405C4CEF1; Thu, 4 Sep 2025 15:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757000029; bh=lTZqQHKY5f6b0Z6ndwsO52NnSth+sQTGRN7Fb8avZeQ=; h=From:To:Cc:Subject:Date:Reply-to:From; b=GqVJ9zFbqVZhWP62sjiim+3DVrlNlwEK6qg8zoj1VgTkEC8JfsPl6R+bWCOESidLy Tn3g2Hw38Qsd9F92sbInrsyFQWGoSnA82flLsPttmOochw+8k/q9czswUiGXU5MNXS XbSBx3cz5A2jSUNaizqSiSuGa0bofV60+lfP0dzQ= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38682: i2c: core: Fix double-free of fwnode in i2c_unregister_device() Date: Thu, 4 Sep 2025 17:32:47 +0200 Message-ID: <2025090446-CVE-2025-38682-a90a@gregkh> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=2818; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=enA1haU7w6cyoUUtyEyPU36pySTJ/fcB2f6E5/7PcDY=; b=owGbwMvMwCRo6H6F97bub03G02pJDBk7N8od/rro575zOXJd8yxNNgvJ1F62WrpmYv1ZO8vJG 9R0DNa3dcSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEuq0ZFjRKG1rdsqiQcrSM Pr+t5f2UM6GR7QwLZvJ3MOcfv+1pWfxhn5TMl+VzeVJ7AQ== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: i2c: core: Fix double-free of fwnode in i2c_unregister_device() Before commit df6d7277e552 ("i2c: core: Do not dereference fwnode in struct device"), i2c_unregister_device() only called fwnode_handle_put() on of_node-s in the form of calling of_node_put(client->dev.of_node). But after this commit the i2c_client's fwnode now unconditionally gets fwnode_handle_put() on it. When the i2c_client has no primary (ACPI / OF) fwnode but it does have a software fwnode, the software-node will be the primary node and fwnode_handle_put() will put() it. But for the software fwnode device_remove_software_node() will also put() it leading to a double free: [ 82.665598] ------------[ cut here ]------------ [ 82.665609] refcount_t: underflow; use-after-free. [ 82.665808] WARNING: CPU: 3 PID: 1502 at lib/refcount.c:28 refcount_warn_saturate+0xba/0x11 ... [ 82.666830] RIP: 0010:refcount_warn_saturate+0xba/0x110 ... [ 82.666962] [ 82.666971] i2c_unregister_device+0x60/0x90 Fix this by not calling fwnode_handle_put() when the primary fwnode is a software-node. The Linux kernel CVE team has assigned CVE-2025-38682 to this issue. Affected and fixed versions =========================== Issue introduced in 6.16 with commit df6d7277e5525d6cce63127dd93ebec4c6354fa0 and fixed in 6.16.2 with commit ffe02f7c4e36090154646612e67d331832f92037 Issue introduced in 6.16 with commit df6d7277e5525d6cce63127dd93ebec4c6354fa0 and fixed in 6.17-rc1 with commit 1c24e5fc0c7096e00c202a6a3e0c342c1afb47c2 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-38682 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/i2c/i2c-core-base.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/ffe02f7c4e36090154646612e67d331832f92037 https://git.kernel.org/stable/c/1c24e5fc0c7096e00c202a6a3e0c342c1afb47c2