linux-stable/net/handshake
Moritz Wanzenböck 450d6bf74c net/handshake: fix file ref count in handshake_nl_accept_doit()
[ Upstream commit 7798b59409 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-02 09:36:54 +01:00
..
.kunitconfig net/handshake: Add Kunit tests for the handshake consumer API 2023-04-19 18:48:48 -07:00
Makefile net/handshake: Add Kunit tests for the handshake consumer API 2023-04-19 18:48:48 -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-10-06 13:15:57 +02:00
handshake.h net/handshake: remove fput() that causes use-after-free 2023-06-14 22:26:37 -07:00
netlink.c net/handshake: fix file ref count in handshake_nl_accept_doit() 2023-11-02 09:36:54 +01:00
request.c net/handshake: remove fput() that causes use-after-free 2023-06-14 22:26:37 -07:00
tlshd.c net/handshake: Enable the SNI extension to work properly 2023-05-24 22:05:24 -07:00
trace.c