From: Sabrina Dubroca <sd@queasysnail.net>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Chris Mason <clm@fb.com>, David Miller <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH net] net: Revert "net: avoid one atomic operation in skb_clone()"
Date: Fri, 21 Nov 2014 19:05:10 +0100 [thread overview]
Message-ID: <20141121180510.GA22112@kria> (raw)
In-Reply-To: <1416589451.8629.119.camel@edumazet-glaptop2.roam.corp.google.com>
Hello Eric,
2014-11-21, 09:04:11 -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> Not sure what I was thinking, but doing anything after
> releasing a refcount is suicidal or/and embarrassing.
>
> By the time we set skb->fclone to SKB_FCLONE_FREE, another cpu
> could have released last reference and freed whole skb.
>
> We potentially corrupt memory or trap if CONFIG_DEBUG_PAGEALLOC is set.
>
> Reported-by: Chris Mason <clm@fb.com>
> Fixes: ce1a4ea3f1258 ("net: avoid one atomic operation in skb_clone()")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/core/skbuff.c | 23 ++++++-----------------
> 1 file changed, 6 insertions(+), 17 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index c16615bfb61e..be4c7deed971 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -552,20 +552,13 @@ static void kfree_skbmem(struct sk_buff *skb)
> case SKB_FCLONE_CLONE:
> fclones = container_of(skb, struct sk_buff_fclones, skb2);
>
> - /* Warning : We must perform the atomic_dec_and_test() before
> - * setting skb->fclone back to SKB_FCLONE_FREE, otherwise
> - * skb_clone() could set clone_ref to 2 before our decrement.
> - * Anyway, if we are going to free the structure, no need to
> - * rewrite skb->fclone.
> + /* The clone portion is available for
> + * fast-cloning again.
> */
> - if (atomic_dec_and_test(&fclones->fclone_ref)) {
> + skb->fclone = SKB_FCLONE_UNAVAILABLE;
Shouldn't that be SKB_FCLONE_FREE ?
> +
> + if (atomic_dec_and_test(&fclones->fclone_ref))
> kmem_cache_free(skbuff_fclone_cache, fclones);
> - } else {
> - /* The clone portion is available for
> - * fast-cloning again.
> - */
> - skb->fclone = SKB_FCLONE_FREE;
like here ^^^^
Thanks,
--
Sabrina
next prev parent reply other threads:[~2014-11-21 18:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-21 16:16 crash in __kfree_skb on v3.18-rc5 with CONFIG_DEBUG_PAGEALLOC Chris Mason
2014-11-21 16:31 ` Eric Dumazet
2014-11-21 16:37 ` Eric Dumazet
2014-11-21 16:47 ` Chris Mason
2014-11-21 16:56 ` Eric Dumazet
2014-11-21 17:18 ` Chris Mason
2014-11-21 16:41 ` Chris Mason
2014-11-21 16:57 ` Chris Mason
2014-11-21 17:04 ` [PATCH net] net: Revert "net: avoid one atomic operation in skb_clone()" Eric Dumazet
2014-11-21 18:05 ` Sabrina Dubroca [this message]
2014-11-21 19:29 ` Eric Dumazet
2014-11-21 19:39 ` Chris Mason
2014-11-21 19:47 ` [PATCH v2 " Eric Dumazet
2014-11-21 20:27 ` David Miller
2014-11-21 21:15 ` Chris Mason
2014-11-21 16:33 ` crash in __kfree_skb on v3.18-rc5 with CONFIG_DEBUG_PAGEALLOC Chris Mason
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=20141121180510.GA22112@kria \
--to=sd@queasysnail.net \
--cc=clm@fb.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.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).