From: Eric Dumazet <eric.dumazet@gmail.com>
To: Li RongQing <lirongqing@baidu.com>, netdev@vger.kernel.org
Cc: edumazet@google.com
Subject: Re: [PATCH] net: clean the sk_frag.page of new cloned socket
Date: Thu, 25 Jan 2018 04:44:05 -0800 [thread overview]
Message-ID: <1516884245.3715.48.camel@gmail.com> (raw)
In-Reply-To: <1516882089-28575-1-git-send-email-lirongqing@baidu.com>
On Thu, 2018-01-25 at 20:08 +0800, Li RongQing wrote:
> Clean the sk_frag.page of new cloned socket, otherwise it will release
> twice wrongly since the reference count of this sk_frag page is not
> increased.
>
> sk_clone_lock() is used to clone a new socket from sock which is in
> listening state and has not sk_frag.page, but a socket has sent data
> and can gets transformed back to a listening socket, will allocate an
> tcp_sock through sk_clone_lock() when a new connection comes in.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> Cc: Eric Dumazet <edumazet@google.com>
> ---
> net/core/sock.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index c0b5b2f17412..c845856f26da 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -1738,6 +1738,8 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
> sk_refcnt_debug_inc(newsk);
> sk_set_socket(newsk, NULL);
> newsk->sk_wq = NULL;
> + newsk->sk_frag.page = NULL;
> + newsk->sk_frag.offset = 0;
>
> if (newsk->sk_prot->sockets_allocated)
> sk_sockets_allocated_inc(newsk);
Good catch.
I suspect this was discovered by some syzkaller/syzbot run ?
I would rather move that in tcp_disconnect() that only fuzzers use,
instead of doing this on every clone and slowing down normal users.
next prev parent reply other threads:[~2018-01-25 12:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 12:08 [PATCH] net: clean the sk_frag.page of new cloned socket Li RongQing
2018-01-25 12:44 ` Eric Dumazet [this message]
2018-01-26 2:09 ` 答复: " Li,Rongqing
2018-01-26 3:03 ` Eric Dumazet
2018-01-26 3:21 ` 答复: " Li,Rongqing
2018-01-26 3:14 ` Eric Dumazet
2018-01-26 3:23 ` 答复: " Li,Rongqing
2018-01-26 5:16 ` Cong Wang
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=1516884245.3715.48.camel@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=edumazet@google.com \
--cc=lirongqing@baidu.com \
--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).