linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "stern@rowland.harvard.edu" <stern@rowland.harvard.edu>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "Zhang, Qiang1" <qiang1.zhang@intel.com>,
	Tejun Heo <tj@kernel.org>,
	syzbot <syzbot+348b571beb5eeb70a582@syzkaller.appspotmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"syzkaller-bugs@googlegroups.com"
	<syzkaller-bugs@googlegroups.com>,
	"balbi@kernel.org" <balbi@kernel.org>
Subject: Re: [syzbot] KASAN: use-after-free Read in dev_uevent
Date: Wed, 2 Mar 2022 14:10:15 -0500	[thread overview]
Message-ID: <Yh/BF2bx1TT3DMPG@rowland.harvard.edu> (raw)
In-Reply-To: <Yhnttj7dA0ZecNj0@kroah.com>

On Sat, Feb 26, 2022 at 10:07:02AM +0100, gregkh@linuxfoundation.org wrote:
> On Fri, Feb 25, 2022 at 10:51:48AM -0500, stern@rowland.harvard.edu wrote:
> > On Fri, Feb 25, 2022 at 09:53:35AM +0100, gregkh@linuxfoundation.org wrote:
> > > The aux bus might make this easier:
> > > 	Documentation/driver-api/auxiliary_bus.rst
> > 
> > Won't this end up changing the user-visible filenames and directories in 
> > sysfs for gadgets and gadget drivers?
> > 
> > For instance, currently gadgets get registered under their UDC driver 
> > name, like "net2280" or "at91".  If we put them on the aux bus then they 
> > will have to get registered under a name looking something like 
> > "udc.gadget.0", i.e., module name, generic device name, and ID number.
> 
> Ah, yeah, that isn't good.
> 
> > We will be forced to use a generic device name because the aux bus does 
> > matching based on it, and we want every gadget driver to be able to 
> > match every UDC.  We don't want some gadget drivers restricted to 
> > net2280 gadgets, others restricted to fotg210 gadgets, and so on.
> 
> So yes, I guess it does need to be a "real" bus, sorry.

It turns out not to be so bad.  In fact there are only five
gadget drivers (that is, instances of struct usb_gadget_driver) in the 
kernel:

	composite_driver_template	(gadget/composite.c)
	configfs_driver_template	(gadget/configfs.c)
	gadgetfs_driver			(gadget/legacy/inode.c)
	driver				(gadget/legacy/raw_gadget.c)
	dbgp_driver			(gadget/legacy/dbgp.c)

Everything else is implemented as a "function" driver.  So the gadget 
driver's name doesn't mean very much to the user anyway.

The interaction between the gadget subsystem and the device core is 
rather peculiar.  Each UDC controller is represented by a pair of device 
structures: the .dev fields in struct usb_udc and struct usb_gadget.  
These two are siblings -- they always have the same parent (see 
usb_add_gadget() in gadget/udc/core.c).  Furthermore, they have the same 
driver; that is, udc->dev.driver is always the same as 
gadget->dev.driver (see udc_bind_to_driver()).  Which is doubly odd, 
because gadget drivers manage only gadget devices, not udc devices.  The 
major difference between them is that the usb_udc is a class device 
whereas the usb_gadget is a "real" device.

Currently neither the udc device nor the gadget device is registered on 
any bus.  IMO it would make sense to leave udc->dev.driver always set to 
NULL, keep the udc devices bus-less, and put the gadget devices on the 
aux bus.

Does that sound reasonable?  I'll work on a patch to do it.

Alan Stern

  reply	other threads:[~2022-03-02 19:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19  5:48 KASAN: use-after-free Read in dev_uevent syzbot
2022-02-20 17:19 ` [syzbot] " syzbot
2022-02-23  6:51   ` Zhang, Qiang1
2022-02-23  7:13     ` gregkh
2022-02-23  8:08       ` Zhang, Qiang1
2022-02-23 11:17   ` Zhang, Qiang1
2022-02-23 11:23     ` Pavel Skripkin
2022-02-23 11:27       ` Pavel Skripkin
2022-02-23 11:29     ` gregkh
2022-02-23 14:38       ` stern
2022-02-23 16:00         ` gregkh
2022-02-23 16:34           ` stern
2022-02-24  1:44             ` Zhang, Qiang1
2022-02-24  3:14               ` Zhang, Qiang1
2022-02-24 21:23                 ` stern
2022-02-24 22:37                   ` gregkh
2022-02-25  2:06                     ` stern
2022-02-25  8:53                       ` gregkh
2022-02-25 15:51                         ` stern
2022-02-26  9:07                           ` gregkh
2022-03-02 19:10                             ` stern [this message]
2022-03-02 21:36                               ` gregkh
2022-02-25  1:45                   ` Zhang, Qiang1
     [not found] <20220223233323.2104-1-hdanton@sina.com>
2022-02-24  0:09 ` syzbot

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=Yh/BF2bx1TT3DMPG@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qiang1.zhang@intel.com \
    --cc=syzbot+348b571beb5eeb70a582@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).