]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit - include/uapi/linux/bpf.h
bpf: Support sk lookup in netns with id 0
authorJoe Stringer <joe@wand.net.nz>
Fri, 30 Nov 2018 23:32:20 +0000 (15:32 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 1 Dec 2018 01:17:38 +0000 (17:17 -0800)
commitf71c6143c2038df1cb43a4b9c90740d14f77467c
treefef0cee90ee0a015b24c8916c6ccb3983b47d688
parentb7df9ada9a7700dbcca1ba53d217c01e3d48179c
bpf: Support sk lookup in netns with id 0

David Ahern and Nicolas Dichtel report that the handling of the netns id
0 is incorrect for the BPF socket lookup helpers: rather than finding
the netns with id 0, it is resolving to the current netns. This renders
the netns_id 0 inaccessible.

To fix this, adjust the API for the netns to treat all negative s32
values as a lookup in the current netns (including u64 values which when
truncated to s32 become negative), while any values with a positive
value in the signed 32-bit integer space would result in a lookup for a
socket in the netns corresponding to that id. As before, if the netns
with that ID does not exist, no socket will be found. Any netns outside
of these ranges will fail to find a corresponding socket, as those
values are reserved for future usage.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Joey Pabalinas <joeypabalinas@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/uapi/linux/bpf.h
net/core/filter.c
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/bpf_helpers.h
tools/testing/selftests/bpf/test_sk_lookup_kern.c