From: Greg KH <gregkh@linuxfoundation.org>
To: Hsin-chen Chuang <chharry@google.com>
Cc: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com,
chromeos-bluetooth-upstreaming@chromium.org,
Hsin-chen Chuang <chharry@chromium.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
Marcel Holtmann <marcel@holtmann.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Ying Hsu <yinghsu@chromium.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v5] Bluetooth: Fix possible race with userspace of sysfs isoc_alt
Date: Tue, 18 Feb 2025 09:23:11 +0100 [thread overview]
Message-ID: <2025021829-clamor-lavish-9126@gregkh> (raw)
In-Reply-To: <CADg1FFf7fONc+HJT8rq55rVFRnS_UxnEPnAGQ476WVe+208_pA@mail.gmail.com>
On Tue, Feb 18, 2025 at 12:24:07PM +0800, Hsin-chen Chuang wrote:
> Hi Greg,
>
> On Mon, Feb 17, 2025 at 4:53 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Feb 17, 2025 at 04:44:35PM +0800, Hsin-chen Chuang wrote:
> > > On Fri, Feb 14, 2025 at 7:37 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> > > >
> > > > On Fri, Feb 14, 2025 at 07:16:17PM +0800, Hsin-chen Chuang wrote:
> > > > > From: Hsin-chen Chuang <chharry@chromium.org>
> > > > >
> > > > > Expose the isoc_alt attr with device group to avoid the racing.
> > > > >
> > > > > Now we create a dev node for btusb. The isoc_alt attr belongs to it and
> > > > > it also becomes the parent device of hci dev.
> > > > >
> > > > > Fixes: b16b327edb4d ("Bluetooth: btusb: add sysfs attribute to control USB alt setting")
> > > >
> > > > Wait, step back, why is this commit needed if you can change the alt
> > > > setting already today through usbfs/libusb without needing to mess with
> > > > the bluetooth stack at all?
> > >
> > > In short: We want to configure the alternate settings without
> > > detaching the btusb driver, while detaching seems necessary for
> > > libusb_set_interface_alt_setting to work (Please correct me if I'm
> > > wrong!)
> >
> > I think changing the alternate setting should work using usbfs as you
> > would send that command to the device, not the interface, so the driver
> > bound to the existing interface would not need to be removed.
>
> I thought USBDEVFS_SETINTERFACE was the right command to begin with,
> but it seems not working in this case.
> The command itself attempts to claim the interface, but the interface
> is already claimed by btusb so it failed with Device or resource busy
>
> drivers/usb/core/devio.c:
> USBDEVFS_SETINTERFACE -> proc_setintf -> checkintf -> claimintf
Ah, ok, thanks for checking. So as you control this device, why not
just disconnect it, change the setting, and then reconnect it?
Also, see my other review comment, how does BlueZ do this today?
thanks,
greg k-h
next prev parent reply other threads:[~2025-02-18 8:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 11:16 [PATCH v5] Bluetooth: Fix possible race with userspace of sysfs isoc_alt Hsin-chen Chuang
2025-02-14 11:24 ` Hsin-chen Chuang
2025-02-14 11:37 ` Greg KH
2025-02-17 8:44 ` Hsin-chen Chuang
2025-02-17 8:53 ` Greg KH
2025-02-18 4:24 ` Hsin-chen Chuang
2025-02-18 8:23 ` Greg KH [this message]
2025-02-18 8:57 ` Hsin-chen Chuang
2025-02-18 9:21 ` Greg KH
2025-02-18 10:01 ` Hsin-chen Chuang
2025-02-18 10:56 ` Greg KH
2025-02-18 12:24 ` Hsin-chen Chuang
2025-02-19 1:54 ` Hsin-chen Chuang
2025-02-17 8:55 ` Greg KH
2025-02-17 9:17 ` Hsin-chen Chuang
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=2025021829-clamor-lavish-9126@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=chharry@chromium.org \
--cc=chharry@google.com \
--cc=chromeos-bluetooth-upstreaming@chromium.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yinghsu@chromium.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).