Patch "bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE" has been added to the 6.0-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

    bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE

to the 6.0-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:
     bpftool-fix-null-pointer-dereference-when-pin-prog-m.patch
and it can be found in the queue-6.0 subdirectory.

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



commit 3a3ddc18628f8f280a788bf50adf8cf20be41f1b
Author: Pu Lehui <pulehui@xxxxxxxxxx>
Date:   Wed Nov 2 16:40:34 2022 +0800

    bpftool: Fix NULL pointer dereference when pin {PROG, MAP, LINK} without FILE
    
    [ Upstream commit 34de8e6e0e1f66e431abf4123934a2581cb5f133 ]
    
    When using bpftool to pin {PROG, MAP, LINK} without FILE,
    segmentation fault will occur. The reson is that the lack
    of FILE will cause strlen to trigger NULL pointer dereference.
    The corresponding stacktrace is shown below:
    
    do_pin
      do_pin_any
        do_pin_fd
          mount_bpffs_for_pin
            strlen(name) <- NULL pointer dereference
    
    Fix it by adding validation to the common process.
    
    Fixes: 75a1e792c335 ("tools: bpftool: Allow all prog/map handles for pinning objects")
    Signed-off-by: Pu Lehui <pulehui@xxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Reviewed-by: Quentin Monnet <quentin@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20221102084034.3342995-1-pulehui@xxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 067e9ea59e3b..3bdbc0ce75b1 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -300,6 +300,9 @@ int do_pin_any(int argc, char **argv, int (*get_fd)(int *, char ***))
 	int err;
 	int fd;
 
+	if (!REQ_ARGS(3))
+		return -EINVAL;
+
 	fd = get_fd(&argc, &argv);
 	if (fd < 0)
 		return fd;



[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