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 D2E2137B40C; Tue, 21 Jul 2026 17:29:36 +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=1784654977; cv=none; b=TYRCEvaUx4CxAKZJM3Q8HZT1cJRlapkRMxS7y1iZUdhWaadOuSehOfI0odB/Z77OyYbmhl+Gybkwd+MeZaii21m36p4Uk8uqn6oz7ihoejtSkdkhsw0KcfDN8jyqg+ZN85XLiagwKV2B0rsxWuiL6iZC/RMYceyCnTCl83NLLjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784654977; c=relaxed/simple; bh=KcZ/CIAY2QxiLFfehMKd9WpHtflZcpmalAD2ueiPgsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P65KqfTjtPRO0IOkRKBChEAc0852mtMXAX0mxfLbWuz+UwuO7O7vnDaD2tUfOMEWlYqM+7GfbhB2T62TGVImXDtS+R4G6xr4hmxynfauN1QuJVylALxKPxHWHhFh7qkPUreN4A37S5uIT90ALw0iLCWGOOipvgK7kA6B+TOnkvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r2LDbLxf; 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="r2LDbLxf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7C831F000E9; Tue, 21 Jul 2026 17:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784654976; bh=lzwxsra4LjFL/RRcjHEBjF+z/ll6ovInF+pwIYorcck=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=r2LDbLxf7YhHJY6HeputR2obaaDSn9hQrhn2oATSnPsxDkuc0hPT6PWwSjZtilZqd Si14dngUy/tbuBj94Mw5uAc7ghv7iSPbZ+fK2D9Vru+L71hS6XNzoTecnUnUHhHsJ4 Fa0eZIB9jPmCVpZP4WMvgLcvWpOYrZxQt6dYvCfg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guangshuo Li , Johan Hovold , Ulf Hansson Subject: [PATCH 7.1 1892/2077] mmc: vub300: fix use-after-free on probe failure Date: Tue, 21 Jul 2026 17:26:05 +0200 Message-ID: <20260721152637.348199074@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@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 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li commit a3b5f242997a3be7404112fd48784881560aea57 upstream. The vub300 driver lifetime-manages its controller state using vub300->kref, with vub300_delete() freeing the mmc host when the last reference is dropped. The probe error path after the inactivity timer has been armed still bypasses that lifetime rule, however, and falls through to mmc_free_host() directly if mmc_add_host() fails. The race window is between arming the inactivity timer and reaching the probe error unwind after mmc_add_host() fails: probe thread timer/workqueue ------------ --------------- kref_init(&vub300->kref) ref = 1 kref_get(&vub300->kref) ref = 2, timer ref add_timer(inactivity_timer) fires after one second | | race window |<----------------------------------------------------> | mmc_add_host(mmc) inactivity timer fires vub300_queue_dead_work() kref_get() ref = 3 queue_work(deadwork) mmc_add_host() fails timer_delete_sync() mmc_free_host(mmc) frees vub300 deadwork runs use-after-free The inactivity timeout is one second, so this would require mmc_add_host() to both fail and take more than one second to do so. This is unlikely to happen in practice, but the error path is still wrong. timer_delete_sync() only waits for the timer callback itself. It does not flush deadwork that the callback may already have queued. As a result, queued deadwork can still hold a kref while the probe error path directly frees the backing mmc host, including the vub300 storage. Fix this by using the same lifetime mechanism as disconnect. Clear vub300->interface so that the timer callback and any queued deadwork return early and drop their references, then drop the initial probe reference and return without falling through to err_free_host. Fixes: 0613ad2401f8 ("mmc: vub300: fix return value check of mmc_add_host()") Signed-off-by: Guangshuo Li Reviewed-by: Johan Hovold Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/vub300.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/mmc/host/vub300.c +++ b/drivers/mmc/host/vub300.c @@ -2336,12 +2336,16 @@ static int vub300_probe(struct usb_inter interface_to_InterfaceNumber(interface)); retval = mmc_add_host(mmc); if (retval) - goto err_delete_timer; + goto err_stop_io; return 0; -err_delete_timer: - timer_delete_sync(&vub300->inactivity_timer); +err_stop_io: + vub300->interface = NULL; + kref_put(&vub300->kref, vub300_delete); + + return retval; + err_free_host: mmc_free_host(mmc); /*