Patch "libbpf: Set close-on-exec flag on gzopen" has been added to the 6.5-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: Set close-on-exec flag on gzopen

to the 6.5-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-set-close-on-exec-flag-on-gzopen.patch
and it can be found in the queue-6.5 subdirectory.

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



commit d0890f12ca00c6909a2c843851e618660158c3f3
Author: Marco Vedovati <marco.vedovati@xxxxxxxxxxxxxxx>
Date:   Thu Aug 10 14:43:53 2023 -0700

    libbpf: Set close-on-exec flag on gzopen
    
    [ Upstream commit 8e50750f122e59ea4cab4b4f696ef22b391bedc9 ]
    
    Enable the close-on-exec flag when using gzopen. This is especially important
    for multithreaded programs making use of libbpf, where a fork + exec could
    race with libbpf library calls, potentially resulting in a file descriptor
    leaked to the new process. This got missed in 59842c5451fe ("libbpf: Ensure
    libbpf always opens files with O_CLOEXEC").
    
    Fixes: 59842c5451fe ("libbpf: Ensure libbpf always opens files with O_CLOEXEC")
    Signed-off-by: Marco Vedovati <marco.vedovati@xxxxxxxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20230810214350.106301-1-martin.kelly@xxxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 7cc79bf764550..e07dff7eba600 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1975,9 +1975,9 @@ static int bpf_object__read_kconfig_file(struct bpf_object *obj, void *data)
 		return -ENAMETOOLONG;
 
 	/* gzopen also accepts uncompressed files. */
-	file = gzopen(buf, "r");
+	file = gzopen(buf, "re");
 	if (!file)
-		file = gzopen("/proc/config.gz", "r");
+		file = gzopen("/proc/config.gz", "re");
 
 	if (!file) {
 		pr_warn("failed to open system Kconfig\n");



[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