LKML Archive on
help / color / mirror / Atom feed
From: Tetsuo Handa <>
To: Hillf Danton <>,
	Luiz Augusto von Dentz <>
	syzbot <>
Subject: Re: [syzbot] general protection fault in hci_release_dev
Date: Mon, 2 Aug 2021 20:02:24 +0900	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>


On 2021/08/02 18:54, Hillf Danton wrote:
> 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);

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.

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02  4:07 syzbot
     [not found] ` <>
2021-08-02 11:02   ` Tetsuo Handa [this message]
2021-08-02 11:38     ` Marcel Holtmann

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [syzbot] general protection fault in hci_release_dev' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).