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 22A582BD11; Mon, 4 Aug 2025 00:40:15 +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=1754268015; cv=none; b=FZPUJuKTYFFajmMr6f3/Qg9HJxfLURS8/Jkx8oBp6CD3+WknFEFjQAMuSOWus9dYhfTKuQAx9ADGK4HLqlZFIw8aaVGL1e2vYEd6sFO+H5Q+djTL3/GASbNfxHX40Kvp+pWF1ofCrW1H9B6k2u+RJiGb9E9sNMiHUi88ZThm6uE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754268015; c=relaxed/simple; bh=2fYUY/uvBo5OdsRFrIpnw5nnkV91xPjunVC+k3DfO7I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DPm+ICwDKprwojGC2VNMcyMLQQwlr3RWTAd5mv5yOOessVzoTuRZ151R+Dj+4bd1BdcIbjM0YTuUjH0obrDZY1y9Lb4MOYorqfTpMeG5JrAf1gNXFWa4YQdplTFFpErdjAPGkPYs9eWOc2jw1ZGsK9e9aGBeoG075UERS/3Bvd8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=shnNe6tO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="shnNe6tO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B879C4CEF0; Mon, 4 Aug 2025 00:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754268015; bh=2fYUY/uvBo5OdsRFrIpnw5nnkV91xPjunVC+k3DfO7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=shnNe6tOkFUaAq2yFmik3wjrehLMmtQazPKazbAebqQ6+tu29iKti4OikIH+Spq64 XajTvPenwXx7OWYF6dpZWadZHShq3SydpqIHH4QTIQVFoJgwwe/0vCgWlyK/Rowglr uc4Yhy0ByqoWgS2ZGZzOEAob2aIKQbXK0sx3I7qji4IYy+Y1i+LAaDYMbZCJwVcXE5 dT1s50s503QBD3BmLMfioCDFg0Ub/TP9A+BbSCFA2RHh6UrLmACdg4rs6G3SIvCA+3 B1FrPNE/Cy4ncG55XVVwJkPrc1C2gd7woifQQbLwHZwF5zvKjuH8ycWoNSu+jsnLGt dz2qb8hlPmwjg== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Oliver Neukum , Alan Stern , Greg Kroah-Hartman , Sasha Levin , thomas.weissschuh@linutronix.de, rdunlap@infradead.org, linux@treblig.org Subject: [PATCH AUTOSEL 5.15 35/44] usb: core: usb_submit_urb: downgrade type check Date: Sun, 3 Aug 2025 20:38:40 -0400 Message-Id: <20250804003849.3627024-35-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250804003849.3627024-1-sashal@kernel.org> References: <20250804003849.3627024-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.189 Content-Transfer-Encoding: 8bit From: Oliver Neukum [ Upstream commit 503bbde34cc3dd2acd231f277ba70c3f9ed22e59 ] Checking for the endpoint type is no reason for a WARN, as that can cause a reboot. A driver not checking the endpoint type must not cause a reboot, as there is just no point in this. We cannot prevent a device from doing something incorrect as a reaction to a transfer. Hence warning for a mere assumption being wrong is not sensible. Signed-off-by: Oliver Neukum Acked-by: Alan Stern Link: https://lore.kernel.org/r/20250612122149.2559724-1-oneukum@suse.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- LLM Generated explanations, may be completely bogus: Based on my analysis of this commit, here is my determination: **Backport Status: YES** This commit should be backported to stable kernel trees for the following reasons: 1. **Fixes a real issue that affects users**: The commit addresses a problem where a `dev_WARN()` can cause system reboots when `panic_on_warn` is enabled. This is a serious issue because a driver bug (not checking endpoint types properly) should not be able to crash the entire system. 2. **Small and contained fix**: The change is minimal - it only replaces `dev_WARN()` with `dev_warn_once()` on line 503 of drivers/usb/core/urb.c. This is a one-line change that doesn't affect any other functionality. 3. **Clear side effects**: The only behavioral change is that: - The warning will no longer trigger a kernel panic when `panic_on_warn` is set - The warning will only be printed once instead of potentially multiple times - No backtrace will be generated 4. **No architectural changes**: This is a simple logging level change that doesn't modify any USB subsystem architecture or functionality. 5. **Affects critical kernel subsystem**: While USB is a critical subsystem, this change actually makes it more stable by preventing potential system crashes. 6. **Follows stable tree rules**: This is clearly a bugfix that improves system stability. The commit message explicitly states that "A driver not checking the endpoint type must not cause a reboot" - this is a stability improvement that prevents denial-of-service scenarios. 7. **Similar fixes in the kernel**: There's precedent for this type of fix, as shown by commit 281cb9d65a95 ("bnxt_en: Make PTP timestamp HWRM more silent") which made a similar conversion from `netdev_WARN_ONCE()` to `netdev_warn_once()` for the same reason. The key insight from the code is that `dev_WARN()` calls `WARN()` which can trigger a kernel panic if `panic_on_warn` is set. This means a malicious or buggy USB device could potentially crash the system just by triggering this warning. Converting to `dev_warn_once()` maintains the diagnostic value while removing the crash risk. drivers/usb/core/urb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 33d62d7e3929..201f8519d9d6 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -499,7 +499,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) /* Check that the pipe's type matches the endpoint's type */ if (usb_pipe_type_check(urb->dev, urb->pipe)) - dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", + dev_warn_once(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", usb_pipetype(urb->pipe), pipetypes[xfertype]); /* Check against a simple/standard policy */ -- 2.39.5