]> git.baikalelectronics.ru Git - kernel.git/commit
net: nfc: fix races in nfc_llcp_sock_get() and nfc_llcp_sock_get_sn()
authorEric Dumazet <edumazet@google.com>
Mon, 9 Oct 2023 12:31:10 +0000 (12:31 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Oct 2023 21:08:54 +0000 (23:08 +0200)
commite4f2611f07c87b3ddb57c4b9e8efcd1e330fc3dc
tree7c06256bf11111c342555f56beab2440a9a8f63b
parentab8075d3a4a8cbeb21d39deb170961dfccf2325b
net: nfc: fix races in nfc_llcp_sock_get() and nfc_llcp_sock_get_sn()

[ Upstream commit 31c07dffafce914c1d1543c135382a11ff058d93 ]

Sili Luo reported a race in nfc_llcp_sock_get(), leading to UAF.

Getting a reference on the socket found in a lookup while
holding a lock should happen before releasing the lock.

nfc_llcp_sock_get_sn() has a similar problem.

Finally nfc_llcp_recv_snl() needs to make sure the socket
found by nfc_llcp_sock_from_sn() does not disappear.

Fixes: 8f50020ed9b8 ("NFC: LLCP late binding")
Reported-by: Sili Luo <rootlab@huawei.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willy Tarreau <w@1wt.eu>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20231009123110.3735515-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/nfc/llcp_core.c