[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025021347-exalted-calculate-b313@gregkh>
Date: Thu, 13 Feb 2025 15:35:45 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Luiz Augusto von Dentz <luiz.dentz@...il.com>
Cc: Hsin-chen Chuang <chharry@...gle.com>, linux-bluetooth@...r.kernel.org,
chromeos-bluetooth-upstreaming@...omium.org,
Hsin-chen Chuang <chharry@...omium.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Johan Hedberg <johan.hedberg@...il.com>,
Marcel Holtmann <marcel@...tmann.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Ying Hsu <yinghsu@...omium.org>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH v4 1/3] Bluetooth: Fix possible race with userspace of
sysfs isoc_alt
On Thu, Feb 13, 2025 at 09:22:28AM -0500, Luiz Augusto von Dentz wrote:
> Hi Greg,
>
> On Thu, Feb 13, 2025 at 8:45 AM Greg KH <gregkh@...uxfoundation.org> wrote:
> >
> > On Thu, Feb 13, 2025 at 09:33:34PM +0800, Hsin-chen Chuang wrote:
> > > On Thu, Feb 13, 2025 at 8:10 PM Greg KH <gregkh@...uxfoundation.org> wrote:
> > > >
> > > > A: http://en.wikipedia.org/wiki/Top_post
> > > > Q: Were do I find info about this thing called top-posting?
> > > > A: Because it messes up the order in which people normally read text.
> > > > Q: Why is top-posting such a bad thing?
> > > > A: Top-posting.
> > > > Q: What is the most annoying thing in e-mail?
> > > >
> > > > A: No.
> > > > Q: Should I include quotations after my reply?
> > > >
> > > > http://daringfireball.net/2007/07/on_top
> > > >
> > > > On Thu, Feb 13, 2025 at 07:57:15PM +0800, Hsin-chen Chuang wrote:
> > > > > The btusb driver data is allocated by devm_kzalloc and is
> > > > > automatically freed on driver detach, so I guess we don't have
> > > > > anything to do here.
> > > >
> > > > What? A struct device should NEVER be allocated with devm_kzalloc.
> > > > That's just not going to work at all.
> > >
> > > Noted. Perhaps that needs to be refactored together.
> > >
> > > >
> > > > > Or perhaps we should move btusb_disconnect's content here? Luiz, what
> > > > > do you think?
> > > >
> > > > I think something is really wrong here. Why are you adding a new struct
> > > > device to the system? What requires that? What is this new device
> > > > going to be used for?
> > >
> > > The new device is only for exposing a new sysfs attribute.
> >
> > That feels crazy.
> >
> > > So originally we had a device called hci_dev, indicating the
> > > implementation of the Bluetooth HCI layer. hci_dev is directly the
> > > child of the usb_interface (the Bluetooth chip connected through USB).
> > > Now I would like to add an attribute for something that's not defined
> > > in the HCI layer, but lower layer only in Bluetooth USB.
> > > Thus we want to rephrase the structure: usb_interface -> btusb (new
> > > device) -> hci_dev, and then we could place the new attribute in the
> > > new device.
> > >
> > > Basically I kept the memory management in btusb unchanged in this
> > > patch, as the new device is only used for a new attribute.
> > > Would you suggest we revise the memory management since we added a
> > > device in this module?
> >
> > If you add a new device in the tree, it HAS to work properly with the
> > driver core (i.e. life cycles are unique, you can't have empty release
> > functions, etc.) Put it on the proper bus it belongs to, bind the
> > needed drivers to it, and have it work that way, don't make a "fake"
> > device for no good reason.
>
> Well we could just introduce it to USB device, since alternate setting
> is a concept that is coming from there, but apparently the likes of
> /sys/bus/usb/devices/usbX/bAlternateSetting is read-only, some
> Bluetooth profiles (HFP) requires switching the alternate setting and
> because Google is switching to handle this via userspace thus why
> there was this request to add a new sysfs to control it.
That's fine, just don't add devices where there shouldn't be devices, or
if you do, make them actually work properly (i.e. do NOT have empty
release callbacks...)
If you want to switch alternate settings in a USB device, do it the
normal way from userspace that has been there for decades! Don't make
up some other random sysfs file for this please, that would be crazy,
and wrong.
So what's wrong with the current api we have today that doesn't work for
bluetooth devices?
thanks,
greg k-h
Powered by blists - more mailing lists