netfilter: xt_owner: Fix for unsafe access of sk->sk_socket
authorPhil Sutter <phil@nwl.cc>
Tue, 5 Dec 2023 20:58:12 +0000 (21:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Dec 2023 17:45:10 +0000 (18:45 +0100)
commit1417b7198546edf59b061cd5953b7d8da2c03253
tree1b830f5e0b9bb97a67a6893693ec69acd8262a57
parentfa72b6e62fa52ce777344cf62d9852e7d938f2d2
netfilter: xt_owner: Fix for unsafe access of sk->sk_socket

[ Upstream commit 7ae836a3d630e146b732fe8ef7d86b243748751f ]

A concurrently running sock_orphan() may NULL the sk_socket pointer in
between check and deref. Follow other users (like nft_meta.c for
instance) and acquire sk_callback_lock before dereferencing sk_socket.

Fixes: 0265ab44bacc ("[NETFILTER]: merge ipt_owner/ip6t_owner in xt_owner")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/xt_owner.c