Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1731381ybe; Tue, 3 Sep 2019 02:38:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhKu26nXMzXqZnR9wE+gABRxIFjwuEvVbo0kjwzEw4Gpk1yhBEzDHsMRCFbm4rUk2sw3KC X-Received: by 2002:a63:6f41:: with SMTP id k62mr29579756pgc.32.1567503507648; Tue, 03 Sep 2019 02:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567503507; cv=none; d=google.com; s=arc-20160816; b=WdA03Kzeg8jlOY7cDToyAxe3BNuHdCJkudT+pDhoZ2sYNgYgXNRK7CSG7Qn+CpwUT3 YOm+SC67Gs2HoFONzU7qnJCDaFuIJZDs+kY8GprMb8aeQoFUThIV9US4fD7tkvOpBO0R qjWu/TNcsnhaA4vYhBue72hqRawDpAiLAiNU4Z7Y3T+fN9T/QtefK1aE6HQeC2a7b72u i+QSG/RuRjqmhOSvARnMhm1CXYO0bbMmVNbi/jyi9GwUbLiTmD+khFkk+zPvWBNnro/9 TvMifpbQw1W68uh1r8VilEDHAzNaKvy/e3BJGDR8Ud1DAVA9FHAIFhsHdRnEm7MPUQUK +QkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7wRLkxuiE/wgcX2qydt52kVJ8vd6+RXBB5CkDwTJdVI=; b=1EQvuGYth9OZliv85iijBI8B8/0/j7oJsgcbv47zc+nkCYL6JKQov4rnN2QKgsTJL0 8jy4c6btcaHndch2DytaqppNUt/xEDyrfE0kpm1eq8SgzeH5zhs5N1AQGLKblXT/z6LG VsMSqDwCJpZwyZ8+klyuWC6iuTZKHuiRS5RfJ6KA3wjwR2EuTFWF2QnSi5KswlRXcKNE 5SdSEQK017IAqQEDmJ2/nRpdZNMONUoSfBDTBp5XTeZ9ON8Cw7ksU8DPLMMGOY040qp7 MO2wIp6tnWk+R7QF4V2JznKdla6dTIpqP1jVNRZ1XRD5a6+BaedBrOKmt3OJwqTUu4c1 QWNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TIdtFNVU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b40si14586572plb.209.2019.09.03.02.38.11; Tue, 03 Sep 2019 02:38:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TIdtFNVU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728592AbfICJhZ (ORCPT + 99 others); Tue, 3 Sep 2019 05:37:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:57386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728188AbfICJhY (ORCPT ); Tue, 3 Sep 2019 05:37:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A07C2173E; Tue, 3 Sep 2019 09:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567503443; bh=1pvNoYETXZHOaryWxGlz7vAjmxKlkKa4yKwwHuSZMVI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TIdtFNVUgfs39r6OrFh5h/UU5nqUa+osiFIglZDVzLqzeVKvAKQOY4uo4MrQ3wTOR iktWgzpMbsenQo1lKN/dw/zbemJ6jAUs1Oh5lHJg1SB++AKnnmuLbc8joRxdOquJR+ +77Rc4gc37ehaPRXnNk0T6OmffvNqIU6xQdYT1so= Date: Tue, 3 Sep 2019 11:37:20 +0200 From: Greg Kroah-Hartman To: Yoshihiro Shimoda Cc: David Howells , "viro@zeniv.linux.org.uk" , Casey Schaufler , Stephen Smalley , "nicolas.dichtel@6wind.com" , "raven@themaw.net" , Christian Brauner , "keyrings@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-security-module@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-api@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 08/11] usb: Add USB subsystem notifications [ver #7] Message-ID: <20190903093720.GD12325@kroah.com> References: <156717343223.2204.15875738850129174524.stgit@warthog.procyon.org.uk> <156717350329.2204.7056537095039252263.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 03, 2019 at 08:53:31AM +0000, Yoshihiro Shimoda wrote: > Hi, > > > From: David Howells, Sent: Friday, August 30, 2019 10:58 PM > > > diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c > > index 9063ede411ae..b8572e4d6a1b 100644 > > --- a/drivers/usb/core/devio.c > > +++ b/drivers/usb/core/devio.c > > @@ -41,6 +41,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "usb.h" > > > > @@ -2660,13 +2661,68 @@ static void usbdev_remove(struct usb_device *udev) > > } > > } > > > > +#ifdef CONFIG_USB_NOTIFICATIONS > > +static noinline void post_usb_notification(const char *devname, > > + enum usb_notification_type subtype, > > + u32 error) > > +{ > > + unsigned int gran = WATCH_LENGTH_GRANULARITY; > > + unsigned int name_len, n_len; > > + u64 id = 0; /* Might want to put a dev# here. */ > > + > > + struct { > > + struct usb_notification n; > > + char more_name[USB_NOTIFICATION_MAX_NAME_LEN - > > + (sizeof(struct usb_notification) - > > + offsetof(struct usb_notification, name))]; > > + } n; > > + > > + name_len = strlen(devname); > > + name_len = min_t(size_t, name_len, USB_NOTIFICATION_MAX_NAME_LEN); > > + n_len = round_up(offsetof(struct usb_notification, name) + name_len, > > + gran) / gran; > > + > > + memset(&n, 0, sizeof(n)); > > + memcpy(n.n.name, devname, n_len); > > + > > + n.n.watch.type = WATCH_TYPE_USB_NOTIFY; > > + n.n.watch.subtype = subtype; > > + n.n.watch.info = n_len; > > + n.n.error = error; > > + n.n.name_len = name_len; > > + > > + post_device_notification(&n.n.watch, id); > > +} > > + > > +void post_usb_device_notification(const struct usb_device *udev, > > + enum usb_notification_type subtype, u32 error) > > +{ > > + post_usb_notification(dev_name(&udev->dev), subtype, error); > > +} > > + > > +void post_usb_bus_notification(const struct usb_bus *ubus, > > This function's argument is struct usb_bus *, but ... > > > + enum usb_notification_type subtype, u32 error) > > +{ > > + post_usb_notification(ubus->bus_name, subtype, error); > > +} > > +#endif > > + > > static int usbdev_notify(struct notifier_block *self, > > unsigned long action, void *dev) > > { > > switch (action) { > > case USB_DEVICE_ADD: > > + post_usb_device_notification(dev, NOTIFY_USB_DEVICE_ADD, 0); > > break; > > case USB_DEVICE_REMOVE: > > + post_usb_device_notification(dev, NOTIFY_USB_DEVICE_REMOVE, 0); > > + usbdev_remove(dev); > > + break; > > + case USB_BUS_ADD: > > + post_usb_bus_notification(dev, NOTIFY_USB_BUS_ADD, 0); > > + break; > > + case USB_BUS_REMOVE: > > + post_usb_bus_notification(dev, NOTIFY_USB_BUS_REMOVE, 0); > > usbdev_remove(dev); > > this function calls usbdev_remove() with incorrect argument if the action > is USB_BUS_REMOVE. So, this seems to cause the following issue [1] on > my environment (R-Car H3 / r8a7795 on next-20190902) [2]. However, I have > no idea how to fix the issue, so I report this issue at the first step. As a few of us just discussed this on IRC, these bus notifiers should probably be dropped as these are the incorrect structure type as you found out. Thanks for the report. greg k-h