All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugeniu Rosca <erosca@de.adit-jv.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: David Howells <dhowells@redhat.com>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Kai-Heng Feng <kai.heng.feng@canonical.com>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	Nicolas Boichat <drinkcat@chromium.org>,
	Mathias Payer <mathias.payer@nebelwelt.net>,
	Kento Kobayashi <Kento.A.Kobayashi@sony.com>,
	Hui Peng <benquike@gmail.com>,
	Raul E Rangel <rrangel@chromium.org>,
	Douglas Anderson <dianders@chromium.org>,
	Jan-Marek Glogowski <glogow@fbihome.de>, Bin Liu <b-liu@ti.com>,
	Colin Ian King <colin.king@canonical.com>,
	Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	Jon Flatley <jflat@chromium.org>,
	Mathieu Malaterre <malat@debian.org>,
	Spyridon Papageorgiou <spapageorgiou@de.adit-jv.com>,
	Joshua Frkuska <joshua_frkuska@mentor.com>,
	"George G . Davis" <george_davis@mentor.com>,
	<yuichi.kusakabe@denso-ten.com>, <yohhei.fukui@denso-ten.com>,
	<natsumi.kamei@denso-ten.com>, <yasano@jp.adit-jv.com>,
	<sliu@de.adit-jv.com>, Eugeniu Rosca <roscaeugeniu@gmail.com>,
	Eugeniu Rosca <erosca@de.adit-jv.com>
Subject: Re: [PATCH] usb: hub: report failure to enumerate uevent to userspace
Date: Wed, 5 Jun 2019 18:55:30 +0200	[thread overview]
Message-ID: <20190605165530.GA15790@vmlxhi-102.adit-jv.com> (raw)
In-Reply-To: <20190605100337.GA9350@kroah.com>

Hi Greg,

We really appreciate your feedback.

On Wed, Jun 05, 2019 at 12:03:37PM +0200, Greg Kroah-Hartman wrote:
> On Wed, Jun 05, 2019 at 11:05:56AM +0200, Eugeniu Rosca wrote:
> > From: Spyridon Papageorgiou <spapageorgiou@de.adit-jv.com>
> > 
> > When a USB device fails to enumerate, only a kernel message is printed.
> > With this patch, a uevent is also generated to notify userspace.
> > Services can monitor for the event through udev and handle failures
> > accordingly.
> > 
> > The "port_enumerate_fail_notify()" function name follows the syntax of
> > "port_over_current_notify()" used in v4.20-rc1
> > commit 201af55da8a398 ("usb: core: added uevent for over-current").
> > 
> > Signed-off-by: Spyridon Papageorgiou <spapageorgiou@de.adit-jv.com>
> > Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
> 
> All we need is one special notifier!  ...
> 
> {grumble}
> 
> This can end up causing loads of new kobject change events to be added,
> overloading what uevents were supposed to be in the first place
> (add/remove of sysfs objects).

I guess that's the case for every other kobject_uevent*(*, KOBJ_CHANGE)
call in the USB subsystem (in case of either HW or code misbehavior).
JFTR, there are around 120 such calls in the entire v5.2-rc3 kernel.

> 
> I just talked with David Howells, and this type of thing really should
> be tied into the new "notifier" interface/api.  That way you can
> register for any specific type of event and just get notified of them
> when they happen.  No need to mess with uevents.
> 
> See his posts on linux-api starting with:
> 	Subject: [RFC][PATCH 0/8] Mount, FS, Block and Keyrings notifications [ver #2]
> for the proposal.
> 
> If we added USB (or really any hardware events) to that interface, would
> it solve the issue you are trying to solve here?

I checked this patch series in linux-fs.git [3], as well as shared my
thoughts with our security and RFS experts, and we came up with the
following questions/remarks:

 - Looking at commit [4], it seems that the new "notifier" interface/api
   forces userspace applications to link against -lkeyutils [5].
   Assuming the latter is designed for ("Kernel key management") [6],
   it may look like the keyutils library is being abused to handle
   the "USB (or really any hardware events)". Do you really plan to
   extend the scope of the library to handle these new tasks?

 - Currently, to be able to get kobject uevent notifications, our
   applications must include "libudev.h" and must link against -ludev.
   By using the feature implemented in [3], we would significantly
   increase the complexity of those applications, particularly because
   they would need to arbitrate between two different categories of
   events received via two different APIs.

 - It is also my assumption that the existing KOBJ_CHANGE events cannot
   be easily converted to the new API, since this would hurt a dozen of
   userland applications relying on them.

Overall, I am quite clueless how to proceed with this patch, except to
keep it in our internal tree, most likely forever. Any
comments/recommendations would be appreciated.

> 
> thanks,
> 
> greg k-h

[1] linux (v5.2-rc3) git grep KOBJ_CHANGE -- drivers/usb/
drivers/usb/core/hub.c:	kobject_uevent_env(&hub_dev->kobj, KOBJ_CHANGE, envp);
drivers/usb/gadget/udc/core.c:	kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
drivers/usb/gadget/udc/core.c:	kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
drivers/usb/phy/phy.c:	kobject_uevent_env(&usb_phy->dev->kobj, KOBJ_CHANGE, envp);
drivers/usb/typec/class.c:	kobject_uevent(&adev->dev.kobj, KOBJ_CHANGE);
drivers/usb/typec/class.c:	kobject_uevent(&port->dev.kobj, KOBJ_CHANGE);
drivers/usb/typec/class.c:	kobject_uevent(&port->dev.kobj, KOBJ_CHANGE);
drivers/usb/typec/class.c:	kobject_uevent(&port->dev.kobj, KOBJ_CHANGE);
drivers/usb/typec/class.c:	kobject_uevent(&port->dev.kobj, KOBJ_CHANGE);

[2] git grep -w KOBJ_CHANGE -- ":\!Documentation" ":\!include" | wc -l
122

[3] https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=notifications
[4] https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?h=16a8aad951990
[5] https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git
[6] https://lwn.net/Articles/210502/ ("Kernel key management")

-- 
Best Regards,
Eugeniu.

  reply	other threads:[~2019-06-05 16:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05  9:05 [PATCH] usb: hub: report failure to enumerate uevent to userspace Eugeniu Rosca
2019-06-05 10:03 ` Greg Kroah-Hartman
2019-06-05 16:55   ` Eugeniu Rosca [this message]
2019-06-05 17:48     ` Greg Kroah-Hartman
2019-06-05 21:19   ` David Howells
2019-06-05 21:22   ` David Howells

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=20190605165530.GA15790@vmlxhi-102.adit-jv.com \
    --to=erosca@de.adit-jv.com \
    --cc=Kento.A.Kobayashi@sony.com \
    --cc=b-liu@ti.com \
    --cc=benquike@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=dhowells@redhat.com \
    --cc=dianders@chromium.org \
    --cc=drinkcat@chromium.org \
    --cc=felipe.balbi@linux.intel.com \
    --cc=george_davis@mentor.com \
    --cc=glogow@fbihome.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jflat@chromium.org \
    --cc=joshua_frkuska@mentor.com \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=malat@debian.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mathias.payer@nebelwelt.net \
    --cc=natsumi.kamei@denso-ten.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=roscaeugeniu@gmail.com \
    --cc=rrangel@chromium.org \
    --cc=sliu@de.adit-jv.com \
    --cc=spapageorgiou@de.adit-jv.com \
    --cc=stern@rowland.harvard.edu \
    --cc=yasano@jp.adit-jv.com \
    --cc=yohhei.fukui@denso-ten.com \
    --cc=yuichi.kusakabe@denso-ten.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 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.