[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230507082556.GG525452@unreal>
Date: Sun, 7 May 2023 11:25:56 +0300
From: Leon Romanovsky <leon@...nel.org>
To: Chuck Lever <cel@...nel.org>
Cc: kernel-tls-handshake@...ts.linux.dev, netdev@...r.kernel.org,
dan.carpenter@...aro.org
Subject: Re: [PATCH v2 2/6] net/handshake: Fix handshake_dup() ref counting
On Fri, May 05, 2023 at 08:46:01PM -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@...cle.com>
>
> If get_unused_fd_flags() fails, we ended up calling fput(sock->file)
> twice.
>
> Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
> Fixes: 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")
> Signed-off-by: Chuck Lever <chuck.lever@...cle.com>
> ---
> net/handshake/netlink.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/handshake/netlink.c b/net/handshake/netlink.c
> index 7ec8a76c3c8a..032d96152e2f 100644
> --- a/net/handshake/netlink.c
> +++ b/net/handshake/netlink.c
> @@ -101,10 +101,8 @@ static int handshake_dup(struct socket *sock)
>
> file = get_file(sock->file);
> newfd = get_unused_fd_flags(O_CLOEXEC);
> - if (newfd < 0) {
> - fput(file);
> + if (newfd < 0)
> return newfd;
IMHO, the better way to fix it is to change handshake_nl_accept_doit()
do not call to fput(sock->file) in error case. It is not right thing
to have a call to handshake_dup() and rely on elevated get_file()
for failure too as it will be problematic for future extension of
handshake_dup().
Thanks
> - }
>
> fd_install(newfd, file);
> return newfd;
>
>
>
Powered by blists - more mailing lists