Patch "bpf: fix bpf_dynptr_slice() to stop return an ERR_PTR." has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bpf: fix bpf_dynptr_slice() to stop return an ERR_PTR.

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bpf-fix-bpf_dynptr_slice-to-stop-return-an-err_ptr.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 673d4c819b0c4f534b32d5111d8799a42db53e99
Author: Kui-Feng Lee <thinker.li@xxxxxxxxx>
Date:   Thu Aug 3 16:12:06 2023 -0700

    bpf: fix bpf_dynptr_slice() to stop return an ERR_PTR.
    
    [ Upstream commit 5426700e6841bf72e652e34b5cec68eadf442435 ]
    
    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@xxxxxxxxxx>
    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@xxxxxxxxx>
    Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
    Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230803231206.1060485-1-thinker.li@xxxxxxxxx
    Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index f12565ba136b0..8c5daa841704b 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2218,7 +2218,7 @@ __bpf_kfunc void *bpf_dynptr_slice(const struct bpf_dynptr_kern *ptr, u32 offset
 	case BPF_DYNPTR_TYPE_XDP:
 	{
 		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;
 
 		bpf_xdp_copy_buf(ptr->data, ptr->offset + offset, buffer, len, false);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux