Patch "selftests/bpf: Fix a fd leak in error paths in open_netns" has been added to the 6.9-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

    selftests/bpf: Fix a fd leak in error paths in open_netns

to the 6.9-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:
     selftests-bpf-fix-a-fd-leak-in-error-paths-in-open_n.patch
and it can be found in the queue-6.9 subdirectory.

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



commit 73df180fc6b61e7abd4237893a1b07ba7743ec5e
Author: Geliang Tang <tanggeliang@xxxxxxxxxx>
Date:   Tue Apr 23 18:35:27 2024 +0800

    selftests/bpf: Fix a fd leak in error paths in open_netns
    
    [ Upstream commit 151f7442436658ee84076681d8f52e987fe147ea ]
    
    As Martin mentioned in review comment, there is an existing bug that
    orig_netns_fd will be leaked in the later "goto fail;" case after
    open("/proc/self/ns/net") in open_netns() in network_helpers.c. This
    patch adds "close(token->orig_netns_fd);" before "free(token);" to
    fix it.
    
    Fixes: a30338840fa5 ("selftests/bpf: Move open_netns() and close_netns() into network_helpers.c")
    Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/a104040b47c3c34c67f3f125cdfdde244a870d3c.1713868264.git.tanggeliang@xxxxxxxxxx
    Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
index 6db27a9088e97..be96bf022316f 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -461,6 +461,8 @@ struct nstoken *open_netns(const char *name)
 
 	return token;
 fail:
+	if (token->orig_netns_fd != -1)
+		close(token->orig_netns_fd);
 	free(token);
 	return NULL;
 }




[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