[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXpEZ4F9341XjuBq@horms.kernel.org>
Date: Wed, 28 Jan 2026 17:16:23 +0000
From: Simon Horman <horms@...nel.org>
To: Kuniyuki Iwashima <kuniyu@...gle.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Ilan Elias <ilane@...com>, Kuniyuki Iwashima <kuni1840@...il.com>,
netdev@...r.kernel.org,
syzbot+f9c5fd1a0874f9069dce@...kaller.appspotmail.com
Subject: Re: [PATCH v2 net] nfc: nci: Fix race between rfkill and
nci_unregister_device().
On Tue, Jan 27, 2026 at 04:03:59AM +0000, Kuniyuki Iwashima wrote:
> syzbot reported the splat below [0] without a repro.
>
> It indicates that struct nci_dev.cmd_wq had been destroyed before
> nci_close_device() was called via rfkill.
>
> nci_dev.cmd_wq is only destroyed in nci_unregister_device(), which
> (I think) was called from virtual_ncidev_close() when syzbot close()d
> an fd of virtual_ncidev.
>
> The problem is that nci_unregister_device() destroys nci_dev.cmd_wq
> first and then calls nfc_unregister_device(), which removes the
> device from rfkill by rfkill_unregister().
>
> So, the device is still visible via rfkill even after nci_dev.cmd_wq
> is destroyed.
>
> Let's unregister the device from rfkill first in nci_unregister_device().
>
> Note that we cannot call nfc_unregister_device() before
> nci_close_device() because
>
> 1) nfc_unregister_device() calls device_del() which frees
> all memory allocated by devm_kzalloc() and linked to
> ndev->conn_info_list
>
> 2) nci_rx_work() could try to queue nci_conn_info to
> ndev->conn_info_list which could be leaked
>
> Thus, nfc_unregister_device() is split into two functions so we
> can remove rfkill interfaces only before nci_close_device().
...
> Fixes: 6a2968aaf50c ("NFC: basic NCI protocol implementation")
> Reported-by: syzbot+f9c5fd1a0874f9069dce@...kaller.appspotmail.com
> Closes: https://lore.kernel.org/all/695e7f56.050a0220.1c677c.036c.GAE@google.com/
> Signed-off-by: Kuniyuki Iwashima <kuniyu@...gle.com>
> ---
> v2:
> * Split nfc_unregister_device() and remove rfkill only
> before nci_close_device()
>
> v1: https://lore.kernel.org/netdev/20260126071359.2693214-1-kuniyu@google.com/
Reviewed-by: Simon Horman <horms@...nel.org>
...
Powered by blists - more mailing lists