All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Greg KH <greg@kroah.com>
Cc: "Geoffrey D. Bennett" <g@b4.vu>,
	USB mailing list <linux-usb@vger.kernel.org>
Subject: [PATCH] USB: core: WARN if pipe direction != setup packet direction
Date: Thu, 20 May 2021 16:20:56 -0400	[thread overview]
Message-ID: <20210520202056.GB1216852@rowland.harvard.edu> (raw)

When a control URB is submitted, the direction indicated by URB's pipe
member is supposed to match the direction indicated by the setup
packet's bRequestType member.  A mismatch could lead to trouble,
depending on which field the host controller drivers use for
determining the actual direction.

This shouldn't ever happen; it would represent a careless bug in a
kernel driver somewhere.  This patch adds a dev_WARN to let people
know about the potential problem.

Suggested-by: "Geoffrey D. Bennett" <g@b4.vu>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---


[as1960]


 drivers/usb/core/urb.c |    3 +++
 1 file changed, 3 insertions(+)

Index: usb-devel/drivers/usb/core/urb.c
===================================================================
--- usb-devel.orig/drivers/usb/core/urb.c
+++ usb-devel/drivers/usb/core/urb.c
@@ -407,6 +407,9 @@ int usb_submit_urb(struct urb *urb, gfp_
 			return -ENOEXEC;
 		is_out = !(setup->bRequestType & USB_DIR_IN) ||
 				!setup->wLength;
+		if (usb_pipeout(urb->pipe) != is_out)
+			dev_WARN(&dev->dev, "BOGUS control dir, pipe %x doesn't match bRequestType %x\n",
+					urb->pipe, setup->bRequestType);
 	} else {
 		is_out = usb_endpoint_dir_out(&ep->desc);
 	}

             reply	other threads:[~2021-05-20 20:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 20:20 Alan Stern [this message]
2021-05-21  8:03 ` [PATCH] USB: core: WARN if pipe direction != setup packet direction Johan Hovold
2021-05-21 12:14   ` Greg KH
2021-05-21 13:17   ` Johan Hovold
2021-05-21 14:41     ` Alan Stern
2021-05-22  2:16     ` [PATCH v2] " Alan Stern
2021-05-22  7:56       ` Johan Hovold
2021-05-24 11:39       ` Johan Hovold
2021-05-24 14:47         ` Alan Stern
2021-05-25 12:40           ` Johan Hovold
2021-05-25 15:12             ` Alan Stern
2021-05-26  7:49               ` Johan Hovold
2021-05-21 14:38   ` [PATCH] " Alan Stern
2021-05-22  7:56     ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210520202056.GB1216852@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=g@b4.vu \
    --cc=greg@kroah.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.