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 4857A1E6DCF; Thu, 30 Jan 2025 14:27:39 +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=1738247259; cv=none; b=MLib2vmkyP68FiVtFAz7opIFnlOTv4cTP/tKoxo+88CNQXyEzH6FdDH1UfeZ5KCs0dicehka34TyktcrzRPW3ENLxGAL181M15cYs3MnQKMXSdidXSGoed+UeT7wKYgDokJ0XGG9DBcS9qyWw31M7r1vb3Pyhf4Eprmej7wGouM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738247259; c=relaxed/simple; bh=cVDEHMLB6I1ypLMxdZKoP4nHnegURcCAG9oaz70N2IY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hpsH7SvIsTFWUGOJm85vAVr9NdXSVfou0JlTtP8X7lNT3Mh1JKtYirQFfG0gLf1S5U4kNG8wl2mTtAnidovlXPldNpPUSzzEmm2DB6JkKhtNAc93E3PmS00p8aK8F62m3LI2uJ+1jDZNLj020kd928UYIZL9x1SCWMa9k5ZMIEg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=D/LOoHZc; 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="D/LOoHZc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C98D3C4CED2; Thu, 30 Jan 2025 14:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738247259; bh=cVDEHMLB6I1ypLMxdZKoP4nHnegURcCAG9oaz70N2IY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/LOoHZcWPr1SQfyP8m1bK97Zs2YWCMr86nSQ6iWR3sANBe3LrFXM3CF2GXa3P/tg /gDhTPI8JDz42t7cKbKRb0UeQlJ4DuPlM8OhTvc+4dqGmfbTmHwKtfZaMmGNMAU1ks 2kXEivnfPhCRKlb1821qCpmK/92oosNj+5bC7MIk= 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.10 129/133] USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb() Date: Thu, 30 Jan 2025 15:01:58 +0100 Message-ID: <20250130140147.720600695@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250130140142.491490528@linuxfoundation.org> References: <20250130140142.491490528@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.10-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 @@ -540,7 +540,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);