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

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



commit b3fafff200c96c89a6eb4c892dd085270a435f00
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 d42d930a3ec4..e4c65d34fe74 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -278,6 +278,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