]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/handshake: restore destructor on submit failure
authorcaoping <caoping@cmss.chinamobile.com>
Thu, 4 Dec 2025 09:10:58 +0000 (01:10 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 10 Dec 2025 08:51:49 +0000 (00:51 -0800)
handshake_req_submit() replaces sk->sk_destruct but never restores it when
submission fails before the request is hashed. handshake_sk_destruct() then
returns early and the original destructor never runs, leaking the socket.
Restore sk_destruct on the error path.

Fixes: 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Cc: stable@vger.kernel.org
Signed-off-by: caoping <caoping@cmss.chinamobile.com>
Link: https://patch.msgid.link/20251204091058.1545151-1-caoping@cmss.chinamobile.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/handshake/request.c

index 274d2c89b6b20799d3024472971a974ad0ff9e64..89435ed755cd0045605d104e71370e4211439ffb 100644 (file)
@@ -276,6 +276,8 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req,
 out_unlock:
        spin_unlock(&hn->hn_lock);
 out_err:
+       /* Restore original destructor so socket teardown still runs on failure */
+       req->hr_sk->sk_destruct = req->hr_odestruct;
        trace_handshake_submit_err(net, req, req->hr_sk, ret);
        handshake_req_destroy(req);
        return ret;