Skip to content

Commit 1ce77c9

Browse files
chuckleverkuba-moo
authored andcommitted
net/handshake: Unpin sock->file if a handshake is cancelled
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 <[email protected]> Fixes: 3b3009e ("net/handshake: Create a NETLINK service for handling handshake requests") Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fc49088 commit 1ce77c9

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

net/handshake/handshake.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct handshake_req {
3131
struct list_head hr_list;
3232
struct rhash_head hr_rhash;
3333
unsigned long hr_flags;
34+
struct file *hr_file;
3435
const struct handshake_proto *hr_proto;
3536
struct sock *hr_sk;
3637
void (*hr_odestruct)(struct sock *sk);

net/handshake/request.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req,
239239
}
240240
req->hr_odestruct = req->hr_sk->sk_destruct;
241241
req->hr_sk->sk_destruct = handshake_sk_destruct;
242+
req->hr_file = sock->file;
242243

243244
ret = -EOPNOTSUPP;
244245
net = sock_net(req->hr_sk);
@@ -334,6 +335,9 @@ bool handshake_req_cancel(struct sock *sk)
334335
return false;
335336
}
336337

338+
/* Request accepted and waiting for DONE */
339+
fput(req->hr_file);
340+
337341
out_true:
338342
trace_handshake_cancel(net, req, sk);
339343

0 commit comments

Comments
 (0)