diff options
| author | Jiayuan Chen <mrpre@163.com> | 2025-01-22 18:09:15 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-27 04:34:16 -0800 |
| commit | 85ca16a12c1f05d0b2419cb3b7c76d5fed6e170a (patch) | |
| tree | 5b2ccacd3f366eb7b6482c80ae0c53a5ae3c644f /net/core | |
| parent | 271e49f8a58edba65bc2b1250a0abaa98c4bfdbe (diff) | |
| download | linux-85ca16a12c1f05d0b2419cb3b7c76d5fed6e170a.tar.gz linux-85ca16a12c1f05d0b2419cb3b7c76d5fed6e170a.tar.bz2 linux-85ca16a12c1f05d0b2419cb3b7c76d5fed6e170a.zip | |
bpf: Disable non stream socket for strparser
[ Upstream commit 5459cce6bf49e72ee29be21865869c2ac42419f5 ]
Currently, only TCP supports strparser, but sockmap doesn't intercept
non-TCP connections to attach strparser. For example, with UDP, although
the read/write handlers are replaced, strparser is not executed due to
the lack of a read_sock operation.
Furthermore, in udp_bpf_recvmsg(), it checks whether the psock has data,
and if not, it falls back to the native UDP read interface, making
UDP + strparser appear to read correctly. According to its commit history,
this behavior is unexpected.
Moreover, since UDP lacks the concept of streams, we intercept it directly.
Fixes: 1fa1fe8ff161 ("bpf, sockmap: Test shutdown() correctly exits epoll and recv()=0")
Signed-off-by: Jiayuan Chen <mrpre@163.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://patch.msgid.link/20250122100917.49845-4-mrpre@163.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/sock_map.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 2f1be9baad05..82a14f131d00 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -303,7 +303,10 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk) write_lock_bh(&sk->sk_callback_lock); if (stream_parser && stream_verdict && !psock->saved_data_ready) { - ret = sk_psock_init_strp(sk, psock); + if (sk_is_tcp(sk)) + ret = sk_psock_init_strp(sk, psock); + else + ret = -EOPNOTSUPP; if (ret) { write_unlock_bh(&sk->sk_callback_lock); sk_psock_put(sk, psock); |
