linux/net/handshake
Moritz Wanzenböck 7798b59409 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: 7ea9c1ec66 ("net/handshake: Fix handshake_dup() ref counting")
Signed-off-by: Moritz Wanzenböck <moritz.wanzenboeck@linbit.com>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Link: https://lore.kernel.org/r/20231019125847.276443-1-moritz.wanzenboeck@linbit.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-10-23 10:19:33 -07:00
..
.kunitconfig net/handshake: Add Kunit tests for the handshake consumer API 2023-04-19 18:48:48 -07:00
alert.c net/handshake: Trace events for TLS Alert helpers 2023-07-28 14:07:59 -07:00
genl.c net: ynl: prefix uAPI header include with uapi/ 2023-05-26 10:30:14 +01:00
genl.h net: ynl: prefix uAPI header include with uapi/ 2023-05-26 10:30:14 +01:00
handshake-test.c net/handshake: Fix memory leak in __sock_create() and sock_alloc_file() 2023-09-20 11:54:49 +01:00
handshake.h net/handshake: Add API for sending TLS Closure alerts 2023-07-28 14:07:59 -07:00
Makefile net/handshake: Add API for sending TLS Closure alerts 2023-07-28 14:07:59 -07:00
netlink.c net/handshake: fix file ref count in handshake_nl_accept_doit() 2023-10-23 10:19:33 -07:00
request.c net/handshake: remove fput() that causes use-after-free 2023-06-14 22:26:37 -07:00
tlshd.c net/handshake: Add API for sending TLS Closure alerts 2023-07-28 14:07:59 -07:00
trace.c net/handshake: Trace events for TLS Alert helpers 2023-07-28 14:07:59 -07:00