summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichal Luczaj <mhal@rbox.co>2024-10-13 18:26:39 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-11-01 01:58:24 +0100
commit12c3e619d34aea5135367606b04c557171a0bf04 (patch)
tree80b9b0a54ffbea4fd7abb5044d8f2bf1e1a65e9a /include
parent9f2ccb6f3888bec45c00121ee43e4e72423b12c1 (diff)
downloadlinux-12c3e619d34aea5135367606b04c557171a0bf04.tar.gz
linux-12c3e619d34aea5135367606b04c557171a0bf04.tar.bz2
linux-12c3e619d34aea5135367606b04c557171a0bf04.zip
bpf, sockmap: SK_DROP on attempted redirects of unsupported af_vsock
[ Upstream commit 9c5bd93edf7b8834aecaa7c340b852d5990d7c78 ] Don't mislead the callers of bpf_{sk,msg}_redirect_{map,hash}(): make sure to immediately and visibly fail the forwarding of unsupported af_vsock packets. Fixes: 634f1a7110b4 ("vsock: support sockmap") Signed-off-by: Michal Luczaj <mhal@rbox.co> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20241013-vsock-fixes-for-redir-v2-1-d6577bbfe742@rbox.co Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/sock.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index c3961050b8e3..e0be8bd98396 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2826,6 +2826,11 @@ static inline bool sk_is_stream_unix(const struct sock *sk)
return sk->sk_family == AF_UNIX && sk->sk_type == SOCK_STREAM;
}
+static inline bool sk_is_vsock(const struct sock *sk)
+{
+ return sk->sk_family == AF_VSOCK;
+}
+
/**
* sk_eat_skb - Release a skb if it is no longer needed
* @sk: socket to eat this skb from