From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754451AbdDDVPC (ORCPT ); Tue, 4 Apr 2017 17:15:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36692 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752798AbdDDVPA (ORCPT ); Tue, 4 Apr 2017 17:15:00 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B664EC05490C Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcelo.leitner@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B664EC05490C Date: Tue, 4 Apr 2017 18:14:54 -0300 From: Marcelo Ricardo Leitner To: Xin Long Cc: Andrey Konovalov , Vlad Yasevich , Neil Horman , "David S. Miller" , linux-sctp@vger.kernel.org, netdev , LKML , Dmitry Vyukov , Eric Dumazet , Kostya Serebryany , syzkaller Subject: Re: net/sctp: list double add warning in sctp_endpoint_add_asoc Message-ID: <20170404211454.GA911@localhost.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 04 Apr 2017 21:15:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 05, 2017 at 01:29:19AM +0800, Xin Long wrote: > On Tue, Apr 4, 2017 at 9:28 PM, Andrey Konovalov wrote: > > Hi, > > > > I've got the following error report while fuzzing the kernel with syzkaller. > > > > On commit a71c9a1c779f2499fb2afc0553e543f18aff6edf (4.11-rc5). > > > > A reproducer and .config are attached. > The script is pretty hard to reproduce the issue in my env. I didn't try running it but I also found the reproducer very complicated to follow. Do you have any plans on having some PoC optimizer, so we can have a more readable code? strace is handy for filtering the noise, yes, but sometimes it doesn't cut it. > But there seems a case to cause a use-after-free when out of snd_buf. > > the case is like: > ----------- > one thread: another thread: > sctp_rcv hold asoc (hold transport) > enqueue the chunk to backlog queue > [refcnt=2] > > sctp_close free assoc > [refcnt=1] > > sctp_sendmsg find asoc > but not hold it > > out of snd_buf > hold asoc, schedule out > [refcnt = 2] > > process backlog and put asoc/transport > [refcnt=1] > > schedule in, put asoc > [refcnt=0] <--- destroyed > > sctp_sendmsg continue It shouldn't be continuing here because sctp_wait_for_sndbuf and sctp_wait_for_connect functions are checking if the asoc is dead already when it schedules in, even though sctp_wait_for_connect return value is ignored and sctp_sendmsg() simply returns after that. Or the checks for dead asocs in there aren't enough somehow. > using asoc, panic