mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: arnd@arndb.de, maksim.salau@gmail.com,
	Florian Fainelli <f.fainelli@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	David Mosberger <davidm@egauge.net>,
	Roger Quadros <rogerq@ti.com>,
	Wolfram Sang <wsa-dev@sang-engineering.com>,
	Oliver Neukum <oneukum@suse.com>,
	Jaejoong Kim <climbbb.kim@gmail.com>,
	linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
Subject: [PATCH] usb: core: Warn if an URB's transfer_buffer is on stack
Date: Sat, 22 Apr 2017 11:37:42 -0700	[thread overview]
Message-ID: <20170422183744.11149-1-f.fainelli@gmail.com> (raw)

We see a large number of fixes to several drivers to remove the usage of
on-stack buffers feeding into USB transfer functions. Make it easier to spot
the offenders by adding a warning in usb_start_wait_urb() for
urb->transfer_buffer to be located on the stack.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/usb/core/message.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 2184ef40a82a..abefddbe9243 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -8,6 +8,7 @@
 #include <linux/pci.h>	/* for scatterlist macros */
 #include <linux/usb.h>
 #include <linux/module.h>
+#include <linux/sched/task_stack.h> /* for object_is_on_stack */
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/timer.h>
@@ -50,6 +51,8 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
 	unsigned long expire;
 	int retval;
 
+	WARN_ON(object_is_on_stack(urb->transfer_buffer));
+
 	init_completion(&ctx.done);
 	urb->context = &ctx;
 	urb->actual_length = 0;
-- 
2.11.0

             reply	other threads:[~2017-04-22 18:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-22 18:37 Florian Fainelli [this message]
2017-04-22 21:31 ` Alan Stern
2017-04-23  6:35   ` Greg Kroah-Hartman
2017-04-23 16:01     ` Alan Stern
2017-04-23 16:54       ` Florian Fainelli
2017-04-24  0:03         ` Alan Stern

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=20170422183744.11149-1-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=arnd@arndb.de \
    --cc=climbbb.kim@gmail.com \
    --cc=davidm@egauge.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=maksim.salau@gmail.com \
    --cc=oneukum@suse.com \
    --cc=rogerq@ti.com \
    --cc=wsa-dev@sang-engineering.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome