aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJoanne Koong <joannelkoong@gmail.com>2022-07-22 15:01:05 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2022-07-26 13:15:33 +0200
commitbbd52178e249fe893ef4a9b87cde5b6c473b0a7c (patch)
treec1e7dbbf8cad8597dbcef6cd9533969c5b28ab80 /net/core
parentselftests/bpf: Don't assign outer source IP to host (diff)
downloadlinux-dev-bbd52178e249fe893ef4a9b87cde5b6c473b0a7c.tar.xz
linux-dev-bbd52178e249fe893ef4a9b87cde5b6c473b0a7c.zip
bpf: Fix bpf_xdp_pointer return pointer
For the case where offset + len == size, bpf_xdp_pointer should return a valid pointer to the addr because that access is permitted. We should only return NULL in the case where offset + len exceeds size. Fixes: 3f364222d032 ("net: xdp: introduce bpf_xdp_pointer utility routine") Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://lore.kernel.org/bpf/20220722220105.2065466-1-joannelkoong@gmail.com
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index dffc7dcda96a..5669248aff25 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3918,7 +3918,7 @@ static void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
offset -= frag_size;
}
out:
- return offset + len < size ? addr + offset : NULL;
+ return offset + len <= size ? addr + offset : NULL;
}
BPF_CALL_4(bpf_xdp_load_bytes, struct xdp_buff *, xdp, u32, offset,