mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
bpf: fix bpf_dynptr_slice() to stop return an ERR_PTR.
[ Upstream commit5426700e68
] 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:66e3a13e7c
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
da2f98973b
commit
dc958014fa
1 changed files with 1 additions and 1 deletions
|
@ -2218,7 +2218,7 @@ __bpf_kfunc void *bpf_dynptr_slice(const struct bpf_dynptr_kern *ptr, u32 offset
|
||||||
case BPF_DYNPTR_TYPE_XDP:
|
case BPF_DYNPTR_TYPE_XDP:
|
||||||
{
|
{
|
||||||
void *xdp_ptr = bpf_xdp_pointer(ptr->data, ptr->offset + offset, len);
|
void *xdp_ptr = bpf_xdp_pointer(ptr->data, ptr->offset + offset, len);
|
||||||
if (xdp_ptr)
|
if (!IS_ERR_OR_NULL(xdp_ptr))
|
||||||
return xdp_ptr;
|
return xdp_ptr;
|
||||||
|
|
||||||
bpf_xdp_copy_buf(ptr->data, ptr->offset + offset, buffer, len, false);
|
bpf_xdp_copy_buf(ptr->data, ptr->offset + offset, buffer, len, false);
|
||||||
|
|
Loading…
Reference in a new issue