From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380900; b=Uh+6MXrxs7f4yBwCQy7dy8jpGrzjyx7IS9PsU7aC7GJQGMe3DLtxNsw1t+f9jxtLhKk6 0nMonJpFRyIIl5hcgDkNYkJhpwlKVtp9yPL2PKAAfoj/fTk3IbDG1HvTiN6y9MCG870kB SQVBcMjp6BEAoKjOM8HJ6d8M+OLR75Mj1Mbs7+K9clYmJbNXleLmX9cKhsuxeavfWL+Nc jwAUjltKj8uTiQysvcfRYk2DFw23NXzL92HGtXY9Dn2QH8ddyd3Cd+WJ0DuILjWI9yPKU vYCBk/JiHSdaSy+LAwoXcYhOLjaftI+Qa7FPbzSl0iZtam6WjAItkGkvmbE5+AA6iCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380900; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ZJPMs1ljfjweM9mxYGnAMU7BujnwY5qfGXe8ORAJUK8=; b=BtTqwh6taknpjJd3WIjWKTuuMg7Rz01K3Rfp+riNkI0cRcvGbB31miGsZ6lvG9Hy92DO nzf9fPKiL437vhM+v99ZXtRLqyy8BN7Osy8/guOHsTm07yg/ldwqjntszwcDbVeNc3LV0 2jXCjFaLiLdr73ufDwSZiPiQG85x0ZR4LOLo6Ng2ytEBHA0eyuAr/humv8E6tPVGw9sht rVDivEL+9D1+K7FI/UtnHjlBNjDh7PB+8axtVTKa+qXnfT1aTFQ7H8AIrLNMyzFEFMUVm EJyYl3cucs2MR4vFbYvr1ZSJVU5OSdAdzuLkTn3LdGEHBiUZsONBPIWmkTLAdxq+Gvg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DX5Rhd5s; arc=none 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 051F5606A32D; Fri, 4 Dec 2026 10:41:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=DX5Rhd5s Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75F5E1F000CE; Fri, 4 Dec 2026 10:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380899; bh=ZJPMs1ljfjweM9mxYGnAMU7BujnwY5qfGXe8ORAJUK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DX5Rhd5sojhAbRQ8k34II8w2+crzSDiPwNsG8xr48TlFXdmeKwqWgEV12EGB/Bc+p ANS6hxqKMK2OtSl1C6ftAj2/ClLpAsr5FFEniZdMCXjPtzX+f+/yvAstnSKEoIGiUV /ae27hOPcNAMJL5PmEkFVQ/O3mBqFViUMD2ev1O8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, YuanZhe Liu <25031212351@stu.xidian.edu.cn>, Helge Deller Subject: [PATCH 7.3 471/742] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Date: Fri, 4 Dec 2026 19:05:35 +0900 Message-ID: <20261204100647.665177042@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: YuanZhe Liu <25031212351@stu.xidian.edu.cn> commit e8645fe7419828fd95a90171149c565c1bb72911 upstream. ufx_usb_probe() stores the usb_device pointer in dev->udev without taking a reference, and ufx_usb_disconnect() does not wait for in-flight control transfers. A mode set or blank request that runs while the device is being unplugged - through ufx_ops_set_par() or ufx_ops_blank() on an open /dev/fbN file - keeps issuing synchronous control messages for the whole ufx_set_vid_mode() sequence, including two msleep(1) delays in ufx_config_pix_clk(). Once the disconnect callback returns, the USB core may release the usb_device, and the next ufx_reg_write()/ufx_reg_read() dereferences dev->udev through __create_pipe(): general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1] SMP KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037] RIP: __create_pipe include/linux/usb.h:2031 Call Trace: ufx_set_vid_mode ufx_ops_set_par fb_set_var fb_set_var_from_user store_rotate Take a reference to the usb_device in ufx_usb_probe() and drop it in ufx_free(), so dev->udev and dev->gdev stay valid until the last ufx_data user is gone. The control transfers then fail with -ENODEV instead of dereferencing freed memory. Also return early from ufx_set_vid_mode() while the device is inactive, matching the other transmit paths. That check alone is not enough, because it is not serialized against ufx_usb_disconnect() and the transfer sequence continues after it; it only avoids a long series of failing transfers. Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters") Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> Cc: stable@vger.kernel.org Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/smscufx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/video/fbdev/smscufx.c +++ b/drivers/video/fbdev/smscufx.c @@ -661,8 +661,12 @@ static int ufx_set_vid_mode(struct ufx_d u32 temp; u16 h_total, h_active, h_blank_start, h_blank_end, h_sync_start, h_sync_end; u16 v_total, v_active, v_blank_start, v_blank_end, v_sync_start, v_sync_end; + int status; - int status = ufx_reg_write(dev, 0x8028, 0); + if (!atomic_read(&dev->usb_active)) + return -ENODEV; + + status = ufx_reg_write(dev, 0x8028, 0); check_warn_return(status, "ufx_set_vid_mode error disabling RGB pad"); status = ufx_reg_write(dev, 0x8024, 0); @@ -1067,6 +1071,7 @@ static void ufx_free(struct kref *kref) { struct ufx_data *dev = container_of(kref, struct ufx_data, kref); + usb_put_dev(dev->udev); kfree(dev); } @@ -1610,6 +1615,8 @@ static int ufx_usb_probe(struct usb_inte dev->udev = usbdev; dev->gdev = &usbdev->dev; /* our generic struct device * */ + /* keep the device alive until the last ufx_data user is gone */ + usb_get_dev(usbdev); usb_set_intfdata(interface, dev); dev_dbg(dev->gdev, "%s %s - serial #%s\n",