netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Marco Grassi <marco.gra@gmail.com>,
	Yuchung Cheng <ycheng@google.com>,
	Neal Cardwell <ncardwell@google.com>
Subject: Re: Fw: Linux tcp_xmit_retransmit_queue use after free on 4.8-rc1 / master]
Date: Tue, 16 Aug 2016 13:19:13 -0700	[thread overview]
Message-ID: <CAM_iQpXV-jV0FsAzxt4JYrc6d5LCCLt-5_0uMvM49sV8-+SDDQ@mail.gmail.com> (raw)
In-Reply-To: <1471372748.4943.7.camel@edumazet-glaptop3.roam.corp.google.com>

On Tue, Aug 16, 2016 at 11:39 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Tue, 2016-08-16 at 08:39 -0700, Eric Dumazet wrote:
>> On Tue, 2016-08-16 at 12:45 +0200, Greg KH wrote:
>> > For some reason Marco's emails can't make it to netdev, so I'm
>> > forwarding this on.  Please cc: him on responses.
>>
>> Thanks for the report Greg and Marco.
>>
>> My first guess is this is caused by
>>
>> d41a69f1d390 tcp: make tcp_sendmsg() aware of socket backlog
>>
>> And a combination of funky sendmsg() flags (like FastOpen)
>>
>> I will look at this problem today.
>>
>
> No, above commit was innocent ;)
>
> It looks like the bug is very old, and following patch would fix it.
> I will submit it formally after few tests.
>
>
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index c00e7d51bb18..7717302cab91 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -1523,6 +1523,8 @@ static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unli
>  {
>         if (sk->sk_send_head == skb_unlinked)
>                 sk->sk_send_head = NULL;
> +       if (tcp_sk(sk)->highest_sack == skb_unlinked)
> +               tcp_sk(sk)->highest_sack = NULL;
>  }

Hmm, but from the stack traces it indicates the skb is freed
inside tcp_sendmsg(), which must be:


do_fault:
        if (!skb->len) {
                tcp_unlink_write_queue(skb, sk);
                /* It is the one place in all of TCP, except connection
                 * reset, where we can be unlinking the send_head.
                 */
                tcp_check_send_head(sk, skb);
                sk_wmem_free_skb(sk, skb);
        }

In this case, skb->len == 0 means it is newly allocated skb by
sk_stream_alloc_skb(), so it should not have a chance to be
picked by tp->highest_sack yet b/c the whole function locks
the sock?

I must miss something here.

  reply	other threads:[~2016-08-16 20:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 10:45 Fw: Linux tcp_xmit_retransmit_queue use after free on 4.8-rc1 / master] Greg KH
2016-08-16 15:39 ` Eric Dumazet
2016-08-16 18:39   ` Eric Dumazet
2016-08-16 20:19     ` Cong Wang [this message]
2016-08-16 20:27       ` Eric Dumazet
2016-08-16 20:31         ` Eric Dumazet
2016-08-16 20:32         ` Cong Wang
2016-08-17 11:10           ` Marco Grassi
2016-08-17 12:56     ` [PATCH net] tcp: fix use after free in tcp_xmit_retransmit_queue() Eric Dumazet
2016-08-17 14:09       ` Neal Cardwell
2016-08-17 16:12       ` Cong Wang
2016-08-19  6:24       ` David Miller

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=CAM_iQpXV-jV0FsAzxt4JYrc6d5LCCLt-5_0uMvM49sV8-+SDDQ@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=eric.dumazet@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=marco.gra@gmail.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=ycheng@google.com \
    /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).