public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nfc/nci: fix race with opening and closing
@ 2022-11-16 13:02 Lin Ma
  2022-11-18 12:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Ma @ 2022-11-16 13:02 UTC (permalink / raw)
  To: krzk, davem, kuba, pabeni, netdev, linux-kernel, mudongliangabcd
  Cc: Lin Ma, syzbot+43475bf3cfbd6e41f5b7

Previously we leverage NCI_UNREG and the lock inside nci_close_device to
prevent the race condition between opening a device and closing a
device. However, it still has problem because a failed opening command
will erase the NCI_UNREG flag and allow another opening command to
bypass the status checking.

This fix corrects that by making sure the NCI_UNREG is held.

Reported-by: syzbot+43475bf3cfbd6e41f5b7@syzkaller.appspotmail.com
Fixes: 48b71a9e66c2 ("NFC: add NCI_UNREG flag to eliminate the race")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
V1 -> V2: should be &= instead of =
 net/nfc/nci/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 6a193cce2a75..76ade5d4f55a 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -542,7 +542,7 @@ static int nci_open_device(struct nci_dev *ndev)
 		skb_queue_purge(&ndev->tx_q);
 
 		ndev->ops->close(ndev);
-		ndev->flags = 0;
+		ndev->flags &= BIT(NCI_UNREG);
 	}
 
 done:
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] nfc/nci: fix race with opening and closing
  2022-11-16 13:02 [PATCH v2] nfc/nci: fix race with opening and closing Lin Ma
@ 2022-11-18 12:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-18 12:40 UTC (permalink / raw)
  To: Lin Ma
  Cc: krzk, davem, kuba, pabeni, netdev, linux-kernel, mudongliangabcd,
	syzbot+43475bf3cfbd6e41f5b7

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 16 Nov 2022 21:02:49 +0800 you wrote:
> Previously we leverage NCI_UNREG and the lock inside nci_close_device to
> prevent the race condition between opening a device and closing a
> device. However, it still has problem because a failed opening command
> will erase the NCI_UNREG flag and allow another opening command to
> bypass the status checking.
> 
> This fix corrects that by making sure the NCI_UNREG is held.
> 
> [...]

Here is the summary with links:
  - [v2] nfc/nci: fix race with opening and closing
    https://git.kernel.org/netdev/net/c/0ad6bded175e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-18 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-16 13:02 [PATCH v2] nfc/nci: fix race with opening and closing Lin Ma
2022-11-18 12:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox