All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>,
	netdev <netdev@vger.kernel.org>,
	linux-sctp@vger.kernel.org, Eric Dumazet <eric.dumazet@gmail.com>,
	syzkaller <syzkaller@googlegroups.com>,
	Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>,
	Sasha Levin <sasha.levin@oracle.com>
Subject: Re: [PATCH net] sctp: do sanity checks before migrating the asoc
Date: Thu, 4 Feb 2016 07:47:16 -0200	[thread overview]
Message-ID: <20160204094716.GB31743@localhost.localdomain> (raw)
In-Reply-To: <CACT4Y+bxFFfE1WYFLuki7sjM4bMhMsONKuu5HK9gUuYmP2-eCA@mail.gmail.com>

On Wed, Feb 03, 2016 at 05:13:25PM +0100, Dmitry Vyukov wrote:
> On Tue, Jan 19, 2016 at 9:08 PM, Marcelo Ricardo Leitner
> <marcelo.leitner@gmail.com> wrote:
> > Em 19-01-2016 17:55, Vlad Yasevich escreveu:
> >>
> >> On 01/19/2016 02:31 PM, Marcelo Ricardo Leitner wrote:
> >>>
> >>> Em 19-01-2016 16:37, Vlad Yasevich escreveu:
> >>>>
> >>>> On 01/19/2016 10:59 AM, Marcelo Ricardo Leitner wrote:
> >>>>>
> >>>>> Yes, not thrilled here either about connect-to-self.
> >>>>>
> >>>>> But there is a big difference on how both works. For rx we can just
> >>>>> look for wanted skbs
> >>>>> in rx queue, as they aren't going anywhere, but for tx I don't think we
> >>>>> can easily block
> >>>>> sctp_wfree() call because that may be happening on another CPU (or am I
> >>>>> mistaken here?
> >>>>> sctp still doesn't have RFS but even irqbalance could affect this
> >>>>> AFAICT) and more than
> >>>>> one skb may be in transit at a time.
> >>>>
> >>>>
> >>>> The way it's done now, we wouldn't have to block sctp_wfree.  Chunks are
> >>>> released under
> >>>> lock when they are acked, so we are OK here.  The tx completions will
> >>>> just put 1 byte back
> >>>> to the socket associated with the tx'ed skb, and that should still be ok
> >>>> as
> >>>> sctp_packet_release_owner will call sk_free().
> >>>
> >>>
> >>> Please let me rephrase it. I'm actually worried about the asoc->base.sk
> >>> part of the story
> >>> and how it's fetched in sctp_wfree(). I think we can update that sk
> >>> pointer after
> >>> sock_wfree() has fetched it but not used it yet, possibly leading to
> >>> accounting it twice,
> >>> one during migration and one on sock_wfree.
> >>> In sock_wfree() it will update some sk stats like sk->sk_wmem_alloc,
> >>> among others.
> >>
> >>
> >> sctp_wfree() is only used on skbs that were created as sctp chunks to be
> >> transmitted.
> >> Right now, these skbs aren't actually submitted to the IP or to nic to be
> >> transmitted.
> >> They are queued at the association level (either in transports or in the
> >> outqueue).
> >> They are only freed during ACK processing.
> >>
> >> The ACK processing happens under a socket lock and thus asoc->base.sk can
> >> not move.
> >>
> >> The migration process also happens under a socket lock.  As a result,
> >> during migration
> >> we are guaranteed the chunk queues remain consistent and that
> >> asoc->base.sk linkage
> >> remains consistent.  In fact, if you look at the sctp_sock_migrate, we
> >> lock both
> >> sockets when we reassign the assoc->base.sk so we know both sockets are
> >> properly locked.
> >>
> >> So, I am not sure that what you are worried about can happen.  Please feel
> >> free to
> >> double-check the above of course.
> >
> >
> > Ohh, right. That makes sense. I'll rework the patch. Thanks Vlad.
> 
> 
> Hi Marcelo,
> 
> Any updates on this? I still see the leak.

Hi Dmitry,

No, not yet, and I'll be out for 3 weeks starting monday. So if I don't
get it by sunday, it will be a while, sorry.

  Marcelo

WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>,
	netdev <netdev@vger.kernel.org>,
	linux-sctp@vger.kernel.org, Eric Dumazet <eric.dumazet@gmail.com>,
	syzkaller <syzkaller@googlegroups.com>,
	Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>,
	Sasha Levin <sasha.levin@oracle.com>
Subject: Re: [PATCH net] sctp: do sanity checks before migrating the asoc
Date: Thu, 04 Feb 2016 09:47:16 +0000	[thread overview]
Message-ID: <20160204094716.GB31743@localhost.localdomain> (raw)
In-Reply-To: <CACT4Y+bxFFfE1WYFLuki7sjM4bMhMsONKuu5HK9gUuYmP2-eCA@mail.gmail.com>

On Wed, Feb 03, 2016 at 05:13:25PM +0100, Dmitry Vyukov wrote:
> On Tue, Jan 19, 2016 at 9:08 PM, Marcelo Ricardo Leitner
> <marcelo.leitner@gmail.com> wrote:
> > Em 19-01-2016 17:55, Vlad Yasevich escreveu:
> >>
> >> On 01/19/2016 02:31 PM, Marcelo Ricardo Leitner wrote:
> >>>
> >>> Em 19-01-2016 16:37, Vlad Yasevich escreveu:
> >>>>
> >>>> On 01/19/2016 10:59 AM, Marcelo Ricardo Leitner wrote:
> >>>>>
> >>>>> Yes, not thrilled here either about connect-to-self.
> >>>>>
> >>>>> But there is a big difference on how both works. For rx we can just
> >>>>> look for wanted skbs
> >>>>> in rx queue, as they aren't going anywhere, but for tx I don't think we
> >>>>> can easily block
> >>>>> sctp_wfree() call because that may be happening on another CPU (or am I
> >>>>> mistaken here?
> >>>>> sctp still doesn't have RFS but even irqbalance could affect this
> >>>>> AFAICT) and more than
> >>>>> one skb may be in transit at a time.
> >>>>
> >>>>
> >>>> The way it's done now, we wouldn't have to block sctp_wfree.  Chunks are
> >>>> released under
> >>>> lock when they are acked, so we are OK here.  The tx completions will
> >>>> just put 1 byte back
> >>>> to the socket associated with the tx'ed skb, and that should still be ok
> >>>> as
> >>>> sctp_packet_release_owner will call sk_free().
> >>>
> >>>
> >>> Please let me rephrase it. I'm actually worried about the asoc->base.sk
> >>> part of the story
> >>> and how it's fetched in sctp_wfree(). I think we can update that sk
> >>> pointer after
> >>> sock_wfree() has fetched it but not used it yet, possibly leading to
> >>> accounting it twice,
> >>> one during migration and one on sock_wfree.
> >>> In sock_wfree() it will update some sk stats like sk->sk_wmem_alloc,
> >>> among others.
> >>
> >>
> >> sctp_wfree() is only used on skbs that were created as sctp chunks to be
> >> transmitted.
> >> Right now, these skbs aren't actually submitted to the IP or to nic to be
> >> transmitted.
> >> They are queued at the association level (either in transports or in the
> >> outqueue).
> >> They are only freed during ACK processing.
> >>
> >> The ACK processing happens under a socket lock and thus asoc->base.sk can
> >> not move.
> >>
> >> The migration process also happens under a socket lock.  As a result,
> >> during migration
> >> we are guaranteed the chunk queues remain consistent and that
> >> asoc->base.sk linkage
> >> remains consistent.  In fact, if you look at the sctp_sock_migrate, we
> >> lock both
> >> sockets when we reassign the assoc->base.sk so we know both sockets are
> >> properly locked.
> >>
> >> So, I am not sure that what you are worried about can happen.  Please feel
> >> free to
> >> double-check the above of course.
> >
> >
> > Ohh, right. That makes sense. I'll rework the patch. Thanks Vlad.
> 
> 
> Hi Marcelo,
> 
> Any updates on this? I still see the leak.

Hi Dmitry,

No, not yet, and I'll be out for 3 weeks starting monday. So if I don't
get it by sunday, it will be a while, sorry.

  Marcelo


  reply	other threads:[~2016-02-04  9:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-30 20:42 net/sctp: sock memory leak Dmitry Vyukov
2015-12-30 20:42 ` Dmitry Vyukov
2015-12-30 20:47 ` Marcelo Ricardo Leitner
2015-12-30 20:47   ` Marcelo Ricardo Leitner
2016-01-15 18:46 ` Marcelo Ricardo Leitner
2016-01-15 18:46   ` Marcelo Ricardo Leitner
2016-01-15 19:11   ` Dmitry Vyukov
2016-01-15 19:11     ` Dmitry Vyukov
2016-01-15 21:40     ` [PATCH net] sctp: do sanity checks before migrating the asoc Marcelo Ricardo Leitner
2016-01-15 21:40       ` Marcelo Ricardo Leitner
2016-01-19 14:19       ` Vlad Yasevich
2016-01-19 14:19         ` Vlad Yasevich
2016-01-19 15:59         ` Marcelo Ricardo Leitner
2016-01-19 15:59           ` Marcelo Ricardo Leitner
2016-01-19 18:37           ` Vlad Yasevich
2016-01-19 18:37             ` Vlad Yasevich
2016-01-19 19:31             ` Marcelo Ricardo Leitner
2016-01-19 19:31               ` Marcelo Ricardo Leitner
2016-01-19 19:55               ` Vlad Yasevich
2016-01-19 19:55                 ` Vlad Yasevich
2016-01-19 20:08                 ` Marcelo Ricardo Leitner
2016-01-19 20:08                   ` Marcelo Ricardo Leitner
2016-02-03 16:13                   ` Dmitry Vyukov
2016-02-03 16:13                     ` Dmitry Vyukov
2016-02-04  9:47                     ` Marcelo Ricardo Leitner [this message]
2016-02-04  9:47                       ` Marcelo Ricardo Leitner
2016-03-02  8:56     ` net/sctp: sock memory leak Dmitry Vyukov
2016-03-02  8:56       ` Dmitry Vyukov
2016-03-02 19:42       ` Marcelo Ricardo Leitner
2016-03-02 19:42         ` Marcelo Ricardo Leitner

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=20160204094716.GB31743@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=dvyukov@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=glider@google.com \
    --cc=kcc@google.com \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sasha.levin@oracle.com \
    --cc=syzkaller@googlegroups.com \
    --cc=vyasevich@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.