From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 AFD9B47ACCA; Sat, 12 Sep 2026 18:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789237160; cv=none; b=rSXD6csNUnV0GGh8PHOMXjJ0bt46OI9ty9Q47KhRoyG3t7WSkvmXAwKGiyTGQfEtCNGNu3ynXgc6N3mA8uMz4JnwbmpnpyN0QZ+i5rzS9nZJIEVAEEcIhvbYRIs9Ua9/mQJxelr/e/N8U1gyrzp5I3JTfGV0TUn/rR+xfKQc7b0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789237160; c=relaxed/simple; bh=iNhC5bmyU1StCXPw0YygqUckIGsLCKfTo3AAKh1z14E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ndbleG4ifkvyda48mm+jvhXWvbld7htX/YToRq06FlmlXD6kvUhuATtsf6aG1PucERg7uxdDhaQ8I35J7LiT07VUI1q4wt40jaGi2XJZwPzo5IsEXIiPMeCCQp80joI7r50Rjs7w8Yn0F0SRVVowUFnpIxe6pUhsC6ngF23O5xI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MhacPtyR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MhacPtyR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86D051F000FF; Sat, 12 Sep 2026 18:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789237157; bh=/O1dlf3W1CVnT7g5E2fcaMON/8bTC570K48sF6Y6Vvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MhacPtyRiTul3BjXBbd7RjNFnnsB7UaCdt3L6UCtqS5oakAFVdrCEKhrnVpMRSbFl AJP5mFiUgmLc83tMO4884QdKV7GDvC4rbouNxka5fwSrQSwbI0endcmnE2/0ZfJxoG Ax08CGGcLMrqjxCwgudwt4jysj1JuoxYow2SVZU8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot@kernel.org, Adrian Hunter , Frank Li , Alexandre Belloni Subject: [PATCH 5.15 201/935] i3c: master: Fix info leak and UAF in device unregister path Date: Sat, 12 Sep 2026 08:53:51 +0200 Message-ID: <20260912065531.425176760@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065526.833703348@linuxfoundation.org> References: <20260912065526.833703348@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter commit d2c743efd2d1ee64e94324664808f623dd865872 upstream. i3c_master_unregister_i3c_devs() clears i3cdev->dev->desc before calling device_unregister(). During device_unregister(), device_del() emits a KOBJ_REMOVE uevent and unbinds the driver while the device descriptor is still expected to be valid. As a result, i3c_device_uevent() and a racing modalias_show() can observe a NULL desc and fall back to an uninitialized stack struct i3c_device_info, leaking kernel stack contents in the generated modalias. Driver .remove() callbacks may also encounter an unexpected NULL desc during unbind. Keep desc valid until device_unregister() has completed. Since device_unregister() drops the device reference and may free the device, take an extra reference with get_device() before unregistering. Clear desc afterwards and release the extra reference with put_device(). This preserves the release-time invariant that desc must be NULL while avoiding both the information leak and a potential use-after-free from writing desc after the device has been released. Reported-by: sashiko-bot@kernel.org Link: https://lore.kernel.org/linux-i3c/20260702190003.8BF741F000E9@smtp.kernel.org/ Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Frank Li Link: https://patch.msgid.link/20260723075747.34049-1-adrian.hunter@intel.com Signed-off-by: Alexandre Belloni Signed-off-by: Greg Kroah-Hartman --- drivers/i3c/master.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2237,11 +2237,12 @@ static void i3c_master_unregister_i3c_de if (!i3cdev->dev) continue; - i3cdev->dev->desc = NULL; - if (device_is_registered(&i3cdev->dev->dev)) + if (device_is_registered(&i3cdev->dev->dev)) { + get_device(&i3cdev->dev->dev); device_unregister(&i3cdev->dev->dev); - else - put_device(&i3cdev->dev->dev); + } + i3cdev->dev->desc = NULL; + put_device(&i3cdev->dev->dev); i3cdev->dev = NULL; } }