netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: netdev@vger.kernel.org, elena.reshetova@intel.com, edumazet@google.com
Subject: Re: [PATCH net] tcp: gso: avoid refcount_t warning from tcp_gso_segment()
Date: Fri, 10 Nov 2017 18:08:42 +0900 (KST)	[thread overview]
Message-ID: <20171110.180842.1962719632798610107.davem@davemloft.net> (raw)
In-Reply-To: <1510096504.2849.100.camel@edumazet-glaptop3.roam.corp.google.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 07 Nov 2017 15:15:04 -0800

> From: Eric Dumazet <edumazet@google.com>
> 
> When a GSO skb of truesize O is segmented into 2 new skbs of truesize N1
> and N2, we want to transfer socket ownership to the new fresh skbs.
> 
> In order to avoid expensive atomic operations on a cache line subject to
> cache bouncing, we replace the sequence :
> 
> refcount_add(N1, &sk->sk_wmem_alloc);
> refcount_add(N2, &sk->sk_wmem_alloc); // repeated by number of segments
> 
> refcount_sub(O, &sk->sk_wmem_alloc);
> 
> by a single
> 
> refcount_add(sum_of(N) - O, &sk->sk_wmem_alloc);
> 
> Problem is :
> 
> In some pathological cases, sum(N) - O might be a negative number, and
> syzkaller bot was apparently able to trigger this trace [1]
> 
> 
> atomic_t was ok with this construct, but we need to take care of the
> negative delta with refcount_t
 ...
> Fixes: 14afee4b6092 ("net: convert sock.sk_wmem_alloc from atomic_t to refcount_t")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: syzbot <syzkaller@googlegroups.com>

Applied and queued up for -stable, thanks Eric.

      reply	other threads:[~2017-11-10  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 23:15 [PATCH net] tcp: gso: avoid refcount_t warning from tcp_gso_segment() Eric Dumazet
2017-11-10  9:08 ` David Miller [this message]

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=20171110.180842.1962719632798610107.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=elena.reshetova@intel.com \
    --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).