bpf: fix bpf_dynptr_slice() to stop return an ERR_PTR.
authorKui-Feng Lee <thinker.li@gmail.com>
Thu, 3 Aug 2023 23:12:06 +0000 (16:12 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Fri, 4 Aug 2023 21:53:15 +0000 (14:53 -0700)
commit5426700e6841bf72e652e34b5cec68eadf442435
treed941223b2a2b53391047fdb6084c2a2bd63bcb9c
parent8a60a041eada0fbfdc7b6b7a10fdf68ae6a840ce
bpf: fix bpf_dynptr_slice() to stop return an ERR_PTR.

Verify if the pointer obtained from bpf_xdp_pointer() is either an error or
NULL before returning it.

The function bpf_dynptr_slice() mistakenly returned an ERR_PTR. Instead of
solely checking for NULL, it should also verify if the pointer returned by
bpf_xdp_pointer() is an error or NULL.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/bpf/d1360219-85c3-4a03-9449-253ea905f9d1@moroto.mountain/
Fixes: 66e3a13e7c2c ("bpf: Add bpf_dynptr_slice and bpf_dynptr_slice_rdwr")
Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230803231206.1060485-1-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
kernel/bpf/helpers.c