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 CCBAC1E3775; Thu, 30 Jan 2025 14:02:23 +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=1738245743; cv=none; b=K/DseeB9hYxQryrhlnDYqeg5p7LsnH9iFIy/YTGHTt4sIFzjviG1dpsT6NVhQ8OnbzBPkPoRhTt05eWhsKuEhAoELxEKmLh/FogxsFCGDHOInm4w8+k4zxDqSoNZUYuY/MYQ2zyq6y4MzixXjJZz3ZoxLErktO47CAQzb8LK/gM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738245743; c=relaxed/simple; bh=u36Fl07e/GGClLsWnjSqIT1UvLKsZnXZMJNpG4oFf/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y149asAdQSMnoeZbJD3OLchsm0ufw46q6ojtHqjuoJag5Z/JdMST9DQr141qDfvNpkx78daW16kHRZwWOUAmgKl1d36BOTQHZ6c07atf8EIOJXUF7dDLugm4NKv945SYXaqIXXfjX91O7HQ4Py6ermnbS3wcr1t39h/VF18CWpI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xqKhM4NI; 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="xqKhM4NI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8A1CC4CED2; Thu, 30 Jan 2025 14:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738245743; bh=u36Fl07e/GGClLsWnjSqIT1UvLKsZnXZMJNpG4oFf/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqKhM4NIA2FuHAnY6hVubiBcEIWP9MYn9BCKZwpy76foJbI7XZeabpSWCKe9HqDm+ K9zDKE2U02QYDl2F0IYkolT07u1tvRz7kuo2RYTTi5Kapti0DNu3i6Cs7CDQV/BKgQ WMa9NNnEGrPW87sQ/zz5FreFCoL5VUYxPi+ddYOA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot , Qasim Ijaz , Johan Hovold Subject: [PATCH 6.12 29/40] USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb() Date: Thu, 30 Jan 2025 14:59:29 +0100 Message-ID: <20250130133500.872759401@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130133459.700273275@linuxfoundation.org> References: <20250130133459.700273275@linuxfoundation.org> User-Agent: quilt/0.68 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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qasim Ijaz commit 575a5adf48b06a2980c9eeffedf699ed5534fade upstream. This patch addresses a null-ptr-deref in qt2_process_read_urb() due to an incorrect bounds check in the following: if (newport > serial->num_ports) { dev_err(&port->dev, "%s - port change to invalid port: %i\n", __func__, newport); break; } The condition doesn't account for the valid range of the serial->port buffer, which is from 0 to serial->num_ports - 1. When newport is equal to serial->num_ports, the assignment of "port" in the following code is out-of-bounds and NULL: serial_priv->current_port = newport; port = serial->port[serial_priv->current_port]; The fix checks if newport is greater than or equal to serial->num_ports indicating it is out-of-bounds. Reported-by: syzbot Closes: https://syzkaller.appspot.com/bug?extid=506479ebf12fe435d01a Fixes: f7a33e608d9a ("USB: serial: add quatech2 usb to serial driver") Cc: # 3.5 Signed-off-by: Qasim Ijaz Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/quatech2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -503,7 +503,7 @@ static void qt2_process_read_urb(struct newport = *(ch + 3); - if (newport > serial->num_ports) { + if (newport >= serial->num_ports) { dev_err(&port->dev, "%s - port change to invalid port: %i\n", __func__, newport);