From: Leon Romanovsky <leon@kernel.org>
To: Chuck Lever <cel@kernel.org>
Cc: kernel-tls-handshake@lists.linux.dev, netdev@vger.kernel.org,
dan.carpenter@linaro.org
Subject: Re: [PATCH v2 2/6] net/handshake: Fix handshake_dup() ref counting
Date: Sun, 7 May 2023 11:25:56 +0300 [thread overview]
Message-ID: <20230507082556.GG525452@unreal> (raw)
In-Reply-To: <168333395123.7813.7077088598355438510.stgit@oracle-102.nfsv4bat.org>
On Fri, May 05, 2023 at 08:46:01PM -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
>
> If get_unused_fd_flags() fails, we ended up calling fput(sock->file)
> twice.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Fixes: 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests")
> Signed-off-by: Chuck Lever <chuck.lever@oracle.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;
>
>
>
next prev parent reply other threads:[~2023-05-07 8:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-06 0:45 [PATCH v2 0/6] Bug fixes for net/handshake Chuck Lever
2023-05-06 0:45 ` [PATCH v2 1/6] net/handshake: Remove unneeded check from handshake_dup() Chuck Lever
2023-05-07 8:20 ` Leon Romanovsky
2023-05-06 0:46 ` [PATCH v2 2/6] net/handshake: Fix handshake_dup() ref counting Chuck Lever
2023-05-06 16:07 ` Simon Horman
2023-05-07 8:25 ` Leon Romanovsky [this message]
2023-05-09 7:04 ` Paolo Abeni
2023-05-09 13:59 ` Chuck Lever III
2023-05-09 14:22 ` Paolo Abeni
2023-05-09 14:32 ` Chuck Lever III
2023-05-16 20:05 ` Chuck Lever III
2023-05-06 0:46 ` [PATCH v2 3/6] net/handshake: Fix uninitialized local variable Chuck Lever
2023-05-07 8:26 ` Leon Romanovsky
2023-05-06 0:46 ` [PATCH v2 4/6] net/handshake: handshake_genl_notify() shouldn't ignore @flags Chuck Lever
2023-05-07 8:26 ` Leon Romanovsky
2023-05-06 0:47 ` [PATCH v2 5/6] net/handshake: Unpin sock->file if a handshake is cancelled Chuck Lever
2023-05-06 16:07 ` Simon Horman
2023-05-07 8:27 ` Leon Romanovsky
2023-05-06 0:47 ` [PATCH v2 6/6] net/handshake: Enable the SNI extension to work properly Chuck Lever
2023-05-07 8:27 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230507082556.GG525452@unreal \
--to=leon@kernel.org \
--cc=cel@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=kernel-tls-handshake@lists.linux.dev \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).