From: 'Greg KH' <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
To: David Laight <David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org>
Cc: Petko Manolov <petkan-nPnTwAqkgEqakBO8gow8eQ@public.gmane.org>,
Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>,
"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH net 2/4] rtl8150: Use heap buffers for all register access
Date: Tue, 7 Feb 2017 13:42:04 +0100 [thread overview]
Message-ID: <20170207124204.GA11883@kroah.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DB027DB75-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
On Tue, Feb 07, 2017 at 11:56:51AM +0000, David Laight wrote:
> From: Greg KH
> > Sent: 07 February 2017 10:52
> > To: Petko Manolov
> > Cc: Ben Hutchings; David Laight; netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > Subject: Re: [PATCH net 2/4] rtl8150: Use heap buffers for all register access
> >
> > On Tue, Feb 07, 2017 at 12:34:52PM +0200, Petko Manolov wrote:
> > > On 17-02-06 16:25:20, Ben Hutchings wrote:
> > > > On Mon, Feb 06, 2017 at 04:09:18PM +0000, David Laight wrote:
> > > > > From: Ben Hutchings
> > > > [...]
> > > > > > + ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
> > > > > > + RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
> > > > > > + indx, 0, buf, size, 500);
> > > > > > + if (ret > 0 && ret <= size)
> > > > > > + memcpy(data, buf, ret);
> > > > >
> > > > > If ret > size something is horridly wrong.
> > > > > Silently not updating the callers buffer at all cannot be right.
> > > >
> > > > Yes, it seems strange to check this. I originally wrote this as ret >
> > > > 0, but then I checked the usbnet core and found __usbnet_read_cmd()
> > > > has the second comparison as well.
> > > >
> > > > > > + kfree(buf);
> > > > > > + return ret;
> > >
> > > Since we return what usb_control_msg() told us to return i assume the error code
> > > will be available to anybody who cares.
> > >
> > > > > I can't help feeling that it would be better to add a wrapper to
> > > > > usb_control_msg() that does the kmalloc() and memcpy()s and
> > > > > drop that into all the call sites.
> > > >
> > > > It might be. Right now I'm trying to patch up a bunch of regressions rather
> > > > than argue over an API change.
> > >
> > > Right, first thing first.
> > >
> > > I am in favor of changing the API, but this should not happen in the stable
> > > releases. I hope Greg will make up his mind and let us know.
> >
> > make up my mind about what? These are bugs, they should be fixed, I'm
> > not taking a total api change at this point in time, sorry.
>
> Adding a usb_control_msg_with_malloc() wrapper is a smaller change than those
> proposed. The smaller churn probably makes back porting other changes easier.
>
> Given the nature of this problem, and how common it seems to be,
> it is almost worth renaming usb_control_msg() itself so that all the
> callers are properly audited.
As this is something that we have been auditing for a decade now, I
don't think you will find all that many instances :)
But for now, fixes like this are fine, if someone wants to tackle the
larger issue here, with a new api function, that would be great.
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-02-07 12:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-04 16:54 [PATCH net 0/4] Fix on-stack USB buffers Ben Hutchings
2017-02-04 16:56 ` [PATCH net 1/4] pegasus: Use heap buffers for all register access Ben Hutchings
2017-02-05 0:30 ` Greg KH
2017-02-06 8:14 ` Petko Manolov
2017-02-06 8:28 ` Greg KH
2017-02-06 12:51 ` Petko Manolov
2017-02-06 13:21 ` Johan Hovold
2017-02-06 13:32 ` Johan Hovold
2017-02-06 13:46 ` Johan Hovold
2017-02-07 10:24 ` Petko Manolov
2017-02-07 10:45 ` Greg KH
[not found] ` <20170207104506.GB32583-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2017-02-07 12:50 ` Petko Manolov
2017-02-06 13:30 ` David Laight
2017-02-07 18:32 ` Steve Calfee
2017-02-08 7:57 ` Petko Manolov
2017-02-04 16:56 ` [PATCH net 2/4] rtl8150: " Ben Hutchings
2017-02-06 8:10 ` Petko Manolov
[not found] ` <20170204165631.GW3442-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
2017-02-06 16:09 ` David Laight
2017-02-06 16:25 ` Ben Hutchings
2017-02-07 10:34 ` Petko Manolov
2017-02-07 10:51 ` Greg KH
2017-02-07 11:56 ` David Laight
[not found] ` <063D6719AE5E284EB5DD2968C1650D6DB027DB75-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2017-02-07 12:42 ` 'Greg KH' [this message]
2017-02-07 12:53 ` Petko Manolov
2017-02-07 13:01 ` Greg KH
2017-02-07 13:20 ` Petko Manolov
2017-02-07 14:14 ` David Laight
2017-02-07 14:52 ` Petko Manolov
[not found] ` <20170204165451.GU3442-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
2017-02-04 16:56 ` [PATCH net 3/4] catc: Combine failure cleanup code in catc_probe() Ben Hutchings
2017-02-04 16:57 ` [PATCH net 4/4] catc: Use heap buffer for memory size test Ben Hutchings
2017-02-07 15:07 ` [PATCH net 0/4] Fix on-stack USB buffers David Miller
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=20170207124204.GA11883@kroah.com \
--to=greg-u8xffu+wg4eavxtiumwx3w@public.gmane.org \
--cc=David.Laight-ZS65k/vG3HxXrIkS9f7CXA@public.gmane.org \
--cc=ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=petkan-nPnTwAqkgEqakBO8gow8eQ@public.gmane.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.