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 00E58A48; Mon, 4 Aug 2025 00:33: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=1754267620; cv=none; b=kWv4/2hmv92FvbHOPHP1TRBwR9u2pObX0R0geBisEGRTtZvSbFcUPmkTx2YPVKTPa+x0Ccizmc8Urz2CVbtkSr+OT2frjf4XXwSTxiipr44fsrjSRev0uL8PiGsN7XU33QGbnVN9BLIK7HJLhvtzYseqR270BvdFidij9Yeo9KY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754267620; c=relaxed/simple; bh=WOErMQXFg85QOBFKEd545AstkCJ+4zdHUHSD49kSkic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sHaHqINk0H7rGxpltPj5R6x0iQChoInf8BRSl8lW86zgmFuwdmr1MNQaeoqx0peV/HeEJkAUdtL7Hl33vlJdMSbgRpGu9GJgNN8KJiqa9FNaUQSL/t1fu1uzrW9PQCEzI6Yiljf2BtDZXTBTKzw4/bvz9rESbiw0Crh2Vh+vosU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W4eKrGCg; 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="W4eKrGCg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C45EC4CEEB; Mon, 4 Aug 2025 00:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754267619; bh=WOErMQXFg85QOBFKEd545AstkCJ+4zdHUHSD49kSkic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W4eKrGCgWdOYwC5TLmSeTKMtO5F9zxgkVk/SIEx3LvQEKR3iZ9piGLHhRkr4aWRwK I23x/2/nc+Y1Xf3k66CRq74T9cMBmCMjiecbB4304ELzNPww2dw5Z0/JZTQ0UKHquY mrp4Xugccye5xjpepJWiu0sqFk7UJq9v1SJlxzA5RP6tifJ7pR+Mc1Fu8G33u+2hwM Y6idfU1iehQPvdxH8O313I/UXeI6jy0GQt9Yrbj4gwh0o/Wn6i1Ql0LGF95U6Ptzyz 7AFtV8ewqTIuAKlIR4QYdJKyUd+Jy2ogE8fLLOv+jQLZwNRLqlDeRL1gwn6l5oGcBj 0uqLTaaXX4y8w== 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 6.12 57/69] usb: core: usb_submit_urb: downgrade type check Date: Sun, 3 Aug 2025 20:31:07 -0400 Message-Id: <20250804003119.3620476-57-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250804003119.3620476-1-sashal@kernel.org> References: <20250804003119.3620476-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 6.12.41 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 7576920e2d5a..9f202f575cec 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c @@ -500,7 +500,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