]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Bluetooth: RFCOMM: avoid leaving dangling sk pointer in rfcomm_sock_alloc()
authorIgnat Korchagin <ignat@cloudflare.com>
Mon, 14 Oct 2024 15:38:02 +0000 (16:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:03:47 +0000 (20:03 +0100)
commit32df687e129ef0f9afcbcc914f7c32deb28fd481
tree8817ca832a69240139e5437390407142afc3bfef
parent61686abc2f3c2c67822aa23ce6f160467ec83d35
Bluetooth: RFCOMM: avoid leaving dangling sk pointer in rfcomm_sock_alloc()

[ Upstream commit 3945c799f12b8d1f49a3b48369ca494d981ac465 ]

bt_sock_alloc() attaches allocated sk object to the provided sock object.
If rfcomm_dlc_alloc() fails, we release the sk object, but leave the
dangling pointer in the sock object, which may cause use-after-free.

Fix this by swapping calls to bt_sock_alloc() and rfcomm_dlc_alloc().

Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20241014153808.51894-4-ignat@cloudflare.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/rfcomm/sock.c