From mboxrd@z Thu Jan 1 00:00:00 1970 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 7520A1A680C; Mon, 13 Apr 2026 16:43:03 +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=1776098583; cv=none; b=PPkwdBObOTVkOtHjMITK3CO65E302L5MSZBzJqj6c7ECPBY2vkMj8H+JTYOscJLGZjYFPFz2iqc1YletR6Bnd6yWdPasDonf0wUJhYfywP/qwtyZlUbqUOg5Ty+vnmDNTmrTEsAv7MB1wo+ZFVwYmlDKyBGrna65HjRzbBlsm6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098583; c=relaxed/simple; bh=OwI75ENEfIAX9+a6hCbJH13PBOaV0DiXgsHNOXmQQ7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=khYV7NPzGS50vl0axqhcPuMVAiI/B58UsXd1MM0962+y2GhQVhspGSOIoqYMfeP8MQvCkGC3A0KQDLtb+nrKmqTwyu0cxFcHJCGYgsU6iGyAOxHF0dqwK8dYtKDLkEthqqhRebruOTSBdnz+6sCatMh1EWkBUkHKl1I3oGQ//i8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=t3RD3q1M; 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="t3RD3q1M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A526C2BCAF; Mon, 13 Apr 2026 16:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776098583; bh=OwI75ENEfIAX9+a6hCbJH13PBOaV0DiXgsHNOXmQQ7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3RD3q1MFyZoSYzZ92JWl+suMrIZsd7hNUsetTEfg6hOzPh3IamvbpK8QsE1JeiHF gnl+KuPdfiKRATnHlmKI8wFFD68/s6PQt6azOvHwuPQIXUpfDmAF2e0+ZEcHxNHu64 9BYpoT2atwKUzD8jmBU+ek6B5uwT0bslG6AMuWA4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gui-Dong Han , Ioana Ciornei , "Christophe Leroy (CS GROUP)" , Sasha Levin Subject: [PATCH 5.10 010/491] bus: fsl-mc: fix use-after-free in driver_override_show() Date: Mon, 13 Apr 2026 17:54:15 +0200 Message-ID: <20260413155819.436681483@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155819.042779211@linuxfoundation.org> References: <20260413155819.042779211@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.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gui-Dong Han [ Upstream commit 148891e95014b5dc5878acefa57f1940c281c431 ] The driver_override_show() function reads the driver_override string without holding the device_lock. However, driver_override_store() uses driver_set_override(), which modifies and frees the string while holding the device_lock. This can result in a concurrent use-after-free if the string is freed by the store function while being read by the show function. Fix this by holding the device_lock around the read operation. Fixes: 1f86a00c1159 ("bus/fsl-mc: add support for 'driver_override' in the mc-bus") Cc: stable@vger.kernel.org Signed-off-by: Gui-Dong Han Reviewed-by: Ioana Ciornei Link: https://lore.kernel.org/r/20251202174438.12658-1-hanguidong02@gmail.com Signed-off-by: Christophe Leroy (CS GROUP) Signed-off-by: Sasha Levin --- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index 8f7448da9258d..49eaf5bddd5ad 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -194,8 +194,12 @@ static ssize_t driver_override_show(struct device *dev, struct device_attribute *attr, char *buf) { struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); + ssize_t len; - return sysfs_emit(buf, "%s\n", mc_dev->driver_override); + device_lock(dev); + len = sysfs_emit(buf, "%s\n", mc_dev->driver_override); + device_unlock(dev); + return len; } static DEVICE_ATTR_RW(driver_override); -- 2.51.0