]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix IPv6 dport byte order in bpf_sk_lookup_udp
authorAndrey Ignatov <rdna@fb.com>
Wed, 7 Nov 2018 21:36:07 +0000 (13:36 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 9 Nov 2018 07:18:01 +0000 (08:18 +0100)
commit17b50f20ce4ce57dec2021406a0b3453854a6746
tree6f66736f84ae1ecbc49c0d744c424f284b719907
parent8a596f77d79b75fb59989fe709132e3621ea5f66
bpf: Fix IPv6 dport byte order in bpf_sk_lookup_udp

Lookup functions in sk_lookup have different expectations about byte
order of provided arguments.

Specifically __inet_lookup, __udp4_lib_lookup and __udp6_lib_lookup
expect dport to be in network byte order and do ntohs(dport) internally.

At the same time __inet6_lookup expects dport to be in host byte order
and correspondingly name the argument hnum.

sk_lookup works correctly with __inet_lookup, __udp4_lib_lookup and
__inet6_lookup with regard to dport. But in __udp6_lib_lookup case it
uses host instead of expected network byte order. It makes result
returned by bpf_sk_lookup_udp for IPv6 incorrect.

The patch fixes byte order of dport passed to __udp6_lib_lookup.

Originally sk_lookup properly handled UDPv6, but not TCPv6. 5efa9243c3a4
fixes TCPv6 but breaks UDPv6.

Fixes: 5efa9243c3a4 ("bpf: Fix IPv6 dport byte-order in bpf_sk_lookup")
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Acked-by: Joe Stringer <joe@wand.net.nz>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/core/filter.c