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 168811BD9D3; Thu, 30 Jan 2025 14:29:04 +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=1738247344; cv=none; b=iCI7z4BcLOdfdXicWEJA7FPiUvggfQQpdq5Hz3WRGt5ztMjY/TBRRBht0VVljpAwsGpFRAHS2rn1+FL4GviI5YTZTxVh/Uvl1kJ8c/zpZfzSPa755Y3Y05bklXQe1zrLQIQ7Vgleny70FwN6VXaUDb+VxC7orUDgmBCKZH8RHSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738247344; c=relaxed/simple; bh=rWfBUhBh2L7cXWId/J/YqsqhTPLf5QJuO1FkFN0xxN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lnlP6Zj79l6R+yxSLtODg84aK7Knlp6qIwud7qDctLvbu6ukO5PBnVIe3hPWs8g4gHlwfCXhRrrFb2622nQLv3inRiXsrFaVTzA9+uhNa/IzlfCNpuS8i9Fxyqx7E3R6rTe2EUeuhslzk9KgpIWMw+4zJlBBMjuzzaZF/yZ/gbo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WqWwqXqa; 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="WqWwqXqa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 957E2C4CED2; Thu, 30 Jan 2025 14:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738247344; bh=rWfBUhBh2L7cXWId/J/YqsqhTPLf5QJuO1FkFN0xxN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WqWwqXqaEqxRAeNu3liKn64Cc5OSPRW2m1ap0COxQ3+WaCPrNLelbBOYz4CVdNyuy KlzThQZ2v9BfycEOtGrDyeshEXHL3XW5wYxmVvHUQHUaw0dhw+SgKKWz+6mLASmusr BX2sznoHOs2IVcBHm3AyLY6Pp4NEwhIOKmoixPFw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot , Qasim Ijaz , Johan Hovold Subject: [PATCH 5.15 19/24] USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb() Date: Thu, 30 Jan 2025 15:02:11 +0100 Message-ID: <20250130140128.061076270@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130140127.295114276@linuxfoundation.org> References: <20250130140127.295114276@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 5.15-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 @@ -525,7 +525,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);