tcp: restrict SO_ATTACH_FILTER to priv users
Subsystems (3)
PATCH 1/1 tcp: restrict SO_ATTACH_FILTER to priv users
This patch restricts the use of SO_ATTACH_FILTER (cBPF) on TCP sockets to users with CAP_NET_ADMIN capability.
This blocks potential side-channel attack where an unprivileged application attaches a filter to leak TCP sequence/acknowledgment numbers.
--- net/core/sock.c | 5 +++++ 1 file changed, 5 insertions(+)
net/core/sock.c +5 -0
@@ -1465,6 +1465,11 @@ int sk_setsockopt(struct sock *sk, int level, int optname,case SO_ATTACH_FILTER : {struct sock_fprog fprog; +if (sk_is_tcp (sk) && + !sockopt_ns_capable (sock_net (sk)->user_ns,CAP_NET_ADMIN )) { + ret = -EPERM ; +break ; + } ret =copy_bpf_fprog_from_user (&fprog, optval, optlen);if (!ret) ret =sk_attach_filter (&fprog, sk);
Signature · 1 line
2.54.0.1032.g2f8565e1d1-goog
Quoted 6 lines · Eric Dumazet
This patch restricts the use of
SO_ATTACH_FILTER(cBPF) on TCP sockets to users withCAP_NET_ADMINcapability.This blocks potential side-channel attack where an unprivileged application attaches a filter to leak TCP sequence/acknowledgment numbers.
Quoted 16 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Eric Dumazet <[email protected]>Reported-by Tamir Shahar <[email protected]>Reported-by Amit Klein <[email protected]>Cc Willem de Bruijn <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Eduard Zingerman <[email protected]>Cc Kumar Kartikeya Dwivedi <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc Jiri Olsa <[email protected]>Cc John Fastabend <[email protected]>Cc Stanislav Fomichev <[email protected]>
Willem de Bruijn
Reviewed-byQuoted 24 lines · Daniel Borkmann
Quoted 6 lines · Eric Dumazet
This patch restricts the use of
SO_ATTACH_FILTER(cBPF) on TCP sockets to users withCAP_NET_ADMINcapability.This blocks potential side-channel attack where an unprivileged application attaches a filter to leak TCP sequence/acknowledgment numbers.
Quoted 16 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Eric Dumazet <[email protected]>Reported-by Tamir Shahar <[email protected]>Reported-by Amit Klein <[email protected]>Cc Willem de Bruijn <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Eduard Zingerman <[email protected]>Cc Kumar Kartikeya Dwivedi <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc Jiri Olsa <[email protected]>Cc John Fastabend <[email protected]>Cc Stanislav Fomichev <[email protected]>
Quoted 1 line
Acked-by Daniel Borkmann <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 23 lines · On Fri, 5 Jun 2026 11:21:34 +0000 you wrote:
This patch restricts the use of
SO_ATTACH_FILTER(cBPF) on TCP sockets to users withCAP_NET_ADMINcapability.This blocks potential side-channel attack where an unprivileged application attaches a filter to leak TCP sequence/acknowledgment numbers.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Eric Dumazet <[email protected]>Reported-by Tamir Shahar <[email protected]>Reported-by Amit Klein <[email protected]>Cc Willem de Bruijn <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Eduard Zingerman <[email protected]>Cc Kumar Kartikeya Dwivedi <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc Jiri Olsa <[email protected]>Cc John Fastabend <[email protected]>Cc Stanislav Fomichev <[email protected]>
Quoted 1 line
[...]
Here is the summary with links:
- [net] tcp: restrict SO_ATTACH_FILTER to priv users
https://git.kernel.org/netdev/net/c/5d39580f68e6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html