Re: [PATCH] sctp: fix refcount bug in sctp_wfree

From: Qiujun Huang
Date: Tue Mar 17 2020 - 00:44:28 EST


On Tue, Mar 17, 2020 at 12:15 PM Marcelo Ricardo Leitner
<marcelo.leitner@xxxxxxxxx> wrote:
>
> On Mon, Mar 16, 2020 at 11:53:24AM +0800, Qiujun Huang wrote:
> > Do accounting for skb's real sk.
> > In some case skb->sk != asoc->base.sk.
>
> This is a too simple description. Please elaborate how this can
> happen in sctp_wfree. Especially considering the construct for
> migrating the tx queue on sctp_sock_migrate(), as both sockets are
> locked while moving the chunks around and the asoc itself is only
> moved in between decrementing and incrementing the refcount:
>
> lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
> sctp_for_each_tx_datachunk(assoc, sctp_clear_owner_w);
> sctp_assoc_migrate(assoc, newsk);
> sctp_for_each_tx_datachunk(assoc, sctp_set_owner_w);
> ...

Yeah, the description is too simple. I'll send v2.

>
> >
> > Reported-and-tested-by: syzbot+cea71eec5d6de256d54d@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> I can't see a positive test result, though. If I didn't loose any
> email, your last test with a patch similar to this one actually
> failed.
> I'm talking about syzbot test result at Message-ID: <000000000000e7736205a0e041f5@xxxxxxxxxx>

I told with syzbot privately avoiding noise :p
Thanks!