Skip to content
Commit 7798b594 authored by Moritz Wanzenböck's avatar Moritz Wanzenböck Committed by Jakub Kicinski
Browse files

net/handshake: fix file ref count in handshake_nl_accept_doit()



If req->hr_proto->hp_accept() fail, we call fput() twice:
Once in the error path, but also a second time because sock->file
is at that point already associated with the file descriptor. Once
the task exits, as it would probably do after receiving an error
reading from netlink, the fd is closed, calling fput() a second time.

To fix, we move installing the file after the error path for the
hp_accept() call. In the case of errors we simply put the unused fd.
In case of success we can use fd_install() to link the sock->file
to the reserved fd.

Fixes: 7ea9c1ec ("net/handshake: Fix handshake_dup() ref counting")
Signed-off-by: default avatarMoritz Wanzenböck <moritz.wanzenboeck@linbit.com>
Reviewed-by: default avatarChuck Lever <chuck.lever@oracle.com>
Link: https://lore.kernel.org/r/20231019125847.276443-1-moritz.wanzenboeck@linbit.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 13454e6e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment