Patch "net/9p: Fix a potential socket leak in p9_socket_open" has been added to the 5.10-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

    net/9p: Fix a potential socket leak in p9_socket_open

to the 5.10-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:
     net-9p-fix-a-potential-socket-leak-in-p9_socket_open.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 1d6869dc255760503f36e4271265a63bffed7149
Author: Wang Hai <wanghai38@xxxxxxxxxx>
Date:   Thu Nov 24 16:10:05 2022 +0800

    net/9p: Fix a potential socket leak in p9_socket_open
    
    [ Upstream commit dcc14cfd7debe11b825cb077e75d91d2575b4cb8 ]
    
    Both p9_fd_create_tcp() and p9_fd_create_unix() will call
    p9_socket_open(). If the creation of p9_trans_fd fails,
    p9_fd_create_tcp() and p9_fd_create_unix() will return an
    error directly instead of releasing the cscoket, which will
    result in a socket leak.
    
    This patch adds sock_release() to fix the leak issue.
    
    Fixes: 6b18662e239a ("9p connect fixes")
    Signed-off-by: Wang Hai <wanghai38@xxxxxxxxxx>
    ACKed-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 400219801e63..deb66635f0f3 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -852,8 +852,10 @@ static int p9_socket_open(struct p9_client *client, struct socket *csocket)
 	struct file *file;
 
 	p = kzalloc(sizeof(struct p9_trans_fd), GFP_KERNEL);
-	if (!p)
+	if (!p) {
+		sock_release(csocket);
 		return -ENOMEM;
+	}
 
 	csocket->sk->sk_allocation = GFP_NOIO;
 	file = sock_alloc_file(csocket, 0, 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