From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Qiujun Huang <hqjagain@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
vyasevich@gmail.com, nhorman@tuxdriver.com,
Jakub Kicinski <kuba@kernel.org>,
linux-sctp@vger.kernel.org, netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
anenbupt@gmail.com
Subject: Re: [PATCH v2] sctp: fix refcount bug in sctp_wfree
Date: Wed, 18 Mar 2020 00:55:49 -0300 [thread overview]
Message-ID: <20200318035549.GC3756@localhost.localdomain> (raw)
In-Reply-To: <CAJRQjocwMzmBiYXwCnupE7hd8qYveBXtUiF2WKBe=TFfJLqcDw@mail.gmail.com>
On Wed, Mar 18, 2020 at 10:45:51AM +0800, Qiujun Huang wrote:
> On Wed, Mar 18, 2020 at 1:30 AM Marcelo Ricardo Leitner
> <marcelo.leitner@gmail.com> wrote:
> >
> > Hi,
> >
> > On Tue, Mar 17, 2020 at 11:55:36PM +0800, Qiujun Huang wrote:
> > > Do accounting for skb's real sk.
> > > In some case skb->sk != asoc->base.sk:
> > >
> > > migrate routing sctp_check_transmitted routing
> > > ------------ ---------------
> > sctp_close();
> > lock_sock(sk2);
> > sctp_primitive_ABORT();
> > sctp_do_sm();
> > sctp_cmd_interpreter();
> > sctp_cmd_process_sack();
> > sctp_outq_sack();
> > sctp_check_transmitted();
> >
> > lock_sock(sk1);
> > sctp_getsockopt_peeloff();
> > sctp_do_peeloff();
> > sctp_sock_migrate();
> > > lock_sock_nested(sk2);
> > > mv the transmitted skb to
> > > the it's local tlist
> >
> >
> > How can sctp_do_sm() be called in the 2nd column so that it bypasses
> > the locks in the left column, allowing this mv to happen?
> >
> > >
> > > sctp_for_each_tx_datachunk(
> > > sctp_clear_owner_w);
> > > sctp_assoc_migrate();
> > > sctp_for_each_tx_datachunk(
> > > sctp_set_owner_w);
> > >
> > > put the skb back to the
> > > assoc lists
> > > ----------------------------------------------------
> > >
> > > The skbs which held bysctp_check_transmitted were not changed
> > > to newsk. They were not dealt with by sctp_for_each_tx_datachunk
> > > (sctp_clear_owner_w/sctp_set_owner_w).
> >
> > It would make sense but I'm missing one step earlier, I'm not seeing
> > how the move to local list is allowed/possible in there. It really
> > shouldn't be possible.
>
> I totally agree that.
> My mistake. So I added some log in my test showing the case:
> The backtrace:
> sctp_close
> sctp_primitive_ABORT
> sctp_do_sm
> sctp_association_free
> __sctp_outq_teardown
> /* Throw away unacknowledged chunks. */
> list_for_each_entry(transport, &q->asoc->peer.transport_addr_list,
> transports) {
> printk("[%d]deal with transmitted %#llx from transport %#llx %s,
> %d\n", raw_smp_processor_id(),
> &transport->transmitted, transport, __func__, __LINE__);
> while ((lchunk = sctp_list_dequeue(&transport->transmitted)) != NULL) {
>
> The trouble skb is from another peer sk in the same asoc, but
> accounted to the base.sk.
Hmm, not sure how you got that out of that debug msg, but okay.
Even if so, how would this trouble skb be accounted on the wrong sk by
then?
Asking because the fix that we want may be a better locking, to
prevent this situation from happening, than compensating for it in
sctp_wfree(). But for that we need to understand how this happened.
Marcelo
next prev parent reply other threads:[~2020-03-18 3:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-17 15:55 [PATCH v2] sctp: fix refcount bug in sctp_wfree Qiujun Huang
2020-03-17 17:30 ` Marcelo Ricardo Leitner
2020-03-18 2:45 ` Qiujun Huang
2020-03-18 3:55 ` Marcelo Ricardo Leitner [this message]
2020-03-18 4:07 ` Qiujun Huang
2020-03-18 4:09 ` Qiujun Huang
2020-03-18 4:22 ` Qiujun Huang
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=20200318035549.GC3756@localhost.localdomain \
--to=marcelo.leitner@gmail.com \
--cc=anenbupt@gmail.com \
--cc=davem@davemloft.net \
--cc=hqjagain@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.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 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).