All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: netdev@vger.kernel.org
Cc: kernel-tls-handshake@lists.linux.dev, dan.carpenter@linaro.org,
	chuck.lever@oracle.com
Subject: [PATCH v3 5/6] net/handshake: Unpin sock->file if a handshake is cancelled
Date: Thu, 11 May 2023 11:49:17 -0400	[thread overview]
Message-ID: <168382014752.84244.8085186506163091822.stgit@91.116.238.104.host.secureserver.net> (raw)
In-Reply-To: <168381978252.84244.1933636428135211300.stgit@91.116.238.104.host.secureserver.net>

From: Chuck Lever <chuck.lever@oracle.com>

If user space never calls DONE, sock->file's reference count remains
elevated. Enable sock->file to be freed eventually in this case.

Reported-by: Jakub Kacinski <kuba@kernel.org>
Fixes: 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 net/handshake/handshake.h |    1 +
 net/handshake/request.c   |    4 ++++
 2 files changed, 5 insertions(+)

diff --git a/net/handshake/handshake.h b/net/handshake/handshake.h
index 4dac965c99df..8aeaadca844f 100644
--- a/net/handshake/handshake.h
+++ b/net/handshake/handshake.h
@@ -31,6 +31,7 @@ struct handshake_req {
 	struct list_head		hr_list;
 	struct rhash_head		hr_rhash;
 	unsigned long			hr_flags;
+	struct file			*hr_file;
 	const struct handshake_proto	*hr_proto;
 	struct sock			*hr_sk;
 	void				(*hr_odestruct)(struct sock *sk);
diff --git a/net/handshake/request.c b/net/handshake/request.c
index 94d5cef3e048..d78d41abb3d9 100644
--- a/net/handshake/request.c
+++ b/net/handshake/request.c
@@ -239,6 +239,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req,
 	}
 	req->hr_odestruct = req->hr_sk->sk_destruct;
 	req->hr_sk->sk_destruct = handshake_sk_destruct;
+	req->hr_file = sock->file;
 
 	ret = -EOPNOTSUPP;
 	net = sock_net(req->hr_sk);
@@ -334,6 +335,9 @@ bool handshake_req_cancel(struct sock *sk)
 		return false;
 	}
 
+	/* Request accepted and waiting for DONE */
+	fput(req->hr_file);
+
 out_true:
 	trace_handshake_cancel(net, req, sk);
 



  parent reply	other threads:[~2023-05-11 15:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 15:46 [PATCH v3 0/6] Bug fixes for net/handshake Chuck Lever
2023-05-11 15:47 ` [PATCH v3 1/6] net/handshake: Remove unneeded check from handshake_dup() Chuck Lever
2023-05-11 15:47 ` [PATCH v3 2/6] net/handshake: Fix handshake_dup() ref counting Chuck Lever
2023-05-11 15:48 ` [PATCH v3 3/6] net/handshake: Fix uninitialized local variable Chuck Lever
2023-05-11 15:48 ` [PATCH v3 4/6] net/handshake: handshake_genl_notify() shouldn't ignore @flags Chuck Lever
2023-05-11 15:49 ` Chuck Lever [this message]
2023-05-11 15:49 ` [PATCH v3 6/6] net/handshake: Enable the SNI extension to work properly Chuck Lever
2023-05-12  8:30 ` [PATCH v3 0/6] Bug fixes for net/handshake patchwork-bot+netdevbpf
2023-05-25  5:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=168382014752.84244.8085186506163091822.stgit@91.116.238.104.host.secureserver.net \
    --to=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dan.carpenter@linaro.org \
    --cc=kernel-tls-handshake@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.