Patch "libbpf: fix an snprintf() overflow check" has been added to the 5.19-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

    libbpf: fix an snprintf() overflow check

to the 5.19-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:
     libbpf-fix-an-snprintf-overflow-check.patch
and it can be found in the queue-5.19 subdirectory.

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



commit 663a128c0ed0856f3545cfe33a2bf9d588e21e22
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Tue Jul 19 12:51:28 2022 +0300

    libbpf: fix an snprintf() overflow check
    
    [ Upstream commit b77ffb30cfc5f58e957571d8541c6a7e3da19221 ]
    
    The snprintf() function returns the number of bytes it *would* have
    copied if there were enough space.  So it can return > the
    sizeof(gen->attach_target).
    
    Fixes: 67234743736a ("libbpf: Generate loader program out of BPF ELF file.")
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Acked-by: Martin KaFai Lau <kafai@xxxxxx>
    Link: https://lore.kernel.org/r/YtZ+oAySqIhFl6/J@kili
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/lib/bpf/gen_loader.c b/tools/lib/bpf/gen_loader.c
index 927745b08014..23f5c46708f8 100644
--- a/tools/lib/bpf/gen_loader.c
+++ b/tools/lib/bpf/gen_loader.c
@@ -533,7 +533,7 @@ void bpf_gen__record_attach_target(struct bpf_gen *gen, const char *attach_name,
 	gen->attach_kind = kind;
 	ret = snprintf(gen->attach_target, sizeof(gen->attach_target), "%s%s",
 		       prefix, attach_name);
-	if (ret == sizeof(gen->attach_target))
+	if (ret >= sizeof(gen->attach_target))
 		gen->error = -ENOSPC;
 }
 



[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