netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Hillf Danton <hdanton@sina.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	BlueZ <linux-bluetooth@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com,
	syzbot <syzbot+47c6d0efbb7fe2f7a5b8@syzkaller.appspotmail.com>
Subject: Re: [syzbot] general protection fault in hci_release_dev
Date: Mon, 2 Aug 2021 13:38:58 +0200	[thread overview]
Message-ID: <F5A39008-A2F6-4DE6-A23F-92ACA1E6CE9C@holtmann.org> (raw)
In-Reply-To: <92ae9eb0-0a9c-f73a-57f3-20059d9e4c21@i-love.sakura.ne.jp>

Hi Tetsuo,

>> To fix what was addressed in e305509e678b3a4a, defer putting hdev until
>> sock is released with sock locked.
>> 
>> Now only for thoughts.
> 
> Thanks for your analysis.
> 
> hci_alloc_dev() is called from hci_uart_register_dev() from  hci_uart_set_proto()
> from hci_uart_tty_ioctl(HCIUARTSETPROTO) via ld->ops->ioctl() from tty_ioctl(),
> and bt_host_release() is called from device_release() from kobject_put() from
> hci_uart_tty_close() from tty_ldisc_kill() from tty_ldisc_release() from
> tty_release_struct() from tty_release() from __fput().
> 
> The problem is that bt_host_release() is expecting that hci_register_dev()
> was called if "struct hci_dev" was allocated by hci_alloc_dev(). In other
> words, hci_register_dev() might not be called before bt_host_release().
> 
> Then, the fix I think is not to call hci_release_dev() when hci_unregister_dev()
> was not called. That is,
> 
> static void bt_host_release(struct device *dev)
> {
>        struct hci_dev *hdev = to_hci_dev(dev);
> +
> +       if (hci_dev_test_flag(hdev, HCI_UNREGISTER))
> +               hci_release_dev(hdev);
>        kfree(hdev);
>        module_put(THIS_MODULE);
> }
> 
> and remove kfree(hdev) from hci_release_dev(), for HCI_UNREGISTER flag is
> set if hci_unregister_dev() was called before bt_host_release() is called.

actually I am wondering if we should just remove the HCI LDISC support. All the tests
are focusing around the fact that you can create a line discipline as unprivileged
user.

To be honest the HCI LDISC support is not in use anymore for anything deployed after
we got around to establish TTY serdev support.

I am worried that we are trying hard to fix something in the Bluetooth core that
is actually a bug in the hci_uart driver and should be fixed solely there. Or that
driver needs to be deprecated. Are other drivers and their lifetime rules also
exhibiting these issues?

Regards

Marcel


      reply	other threads:[~2021-08-02 11:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02  4:07 [syzbot] general protection fault in hci_release_dev syzbot
     [not found] ` <20210802095403.2100-1-hdanton@sina.com>
2021-08-02 11:02   ` Tetsuo Handa
2021-08-02 11:38     ` Marcel Holtmann [this message]

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=F5A39008-A2F6-4DE6-A23F-92ACA1E6CE9C@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=hdanton@sina.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=luiz.von.dentz@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=syzbot+47c6d0efbb7fe2f7a5b8@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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 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).