Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp850136ybi; Fri, 31 May 2019 09:45:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqybzxyfQl29VfaI+1I2wbFWd6eGnL7UYdVm8kykmgXbmwX4jLmQ2G1bUVaVtedgadWSVPRH X-Received: by 2002:a05:6a00:43:: with SMTP id i3mr11329602pfk.113.1559321138799; Fri, 31 May 2019 09:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559321138; cv=none; d=google.com; s=arc-20160816; b=OVk9Wi0wL7guwVB40vWfuAmsi/qnVzjpB0rxqp3WdwPDDOjgbPIv+ZRatrjMl9wbIm WHovB6Ov071lLqCdO+O4dDm3eCaSWkt7BFCTTvHWIHxEyC4oT+5GD2ElhhUtg5v9sDhV JYKukQctXAeL/ufxTMTdFd13oLrogqEL2MXy6AyPW45B1r7BfjTA4gC7HHIzQsfyARdQ DHknCn5zdudxlytsmKhl2ULJYARgiEF5orhBibkawTe+PCq8M9vFIgDGzkzfTfcbu5Zg nbS5BrqnsG8rxZeK4iF9MNI7lz383SKXwm9utpwC78i20VP6i9ydBpfHfg+b4ewyPU0J /tKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=vUxi9XdImtRNckmlG8yWWbMoibHS3PA98TQztUEsYXE=; b=au33ErrIbHsS840z/qmxgwjJKlKZSccizdGqcd73HGSpyMF6FfKufhlpeEpM+0auWV OejYl/hkNBE3A5v8e9uRS3xV2dUgx0HnsGKnzEwRMsbh0uTCvsVZ1wkUmDOsLMSYovxg LlczpkF8O5F2fZZLgPtpgPFsp2WdAxhtR8DYHh2WvKhk7ob1BxRFzLVJd2AKRfmjQ+6C RC9zskFn3h7S4Vltw5GaKTDQd3y5okPoYqrJnzNy3el4+SpMJpx+yC/sKObd9507udC1 wFFGqAWoZCmXXXucfgEMYbRTv3DWq4lk85VN5xvyp/h4bq5shjTTEUnkTqeKQjAZ4iBM 0bLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si6736210pgi.341.2019.05.31.09.45.21; Fri, 31 May 2019 09:45:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbfEaQoB (ORCPT + 99 others); Fri, 31 May 2019 12:44:01 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:49748 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726531AbfEaQn7 (ORCPT ); Fri, 31 May 2019 12:43:59 -0400 Received: from cpe-2606-a000-111b-405a-0-0-0-162e.dyn6.twc.com ([2606:a000:111b:405a::162e] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1hWkd8-0003pv-Az; Fri, 31 May 2019 12:43:52 -0400 Date: Fri, 31 May 2019 12:43:19 -0400 From: Neil Horman To: Marcelo Ricardo Leitner Cc: syzbot , davem@davemloft.net, linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, vyasevich@gmail.com Subject: Re: memory leak in sctp_process_init Message-ID: <20190531164319.GB3828@hmswarspite.think-freely.org> References: <00000000000097abb90589e804fd@google.com> <20190528013600.GM5506@localhost.localdomain> <20190528111550.GA4658@hmswarspite.think-freely.org> <20190529190709.GE31099@hmswarspite.think-freely.org> <20190529233757.GC3713@localhost.localdomain> <20190530142011.GC1966@hmswarspite.think-freely.org> <20190530151705.GD3713@localhost.localdomain> <20190530195634.GD1966@hmswarspite.think-freely.org> <20190531124242.GE3713@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531124242.GE3713@localhost.localdomain> User-Agent: Mutt/1.11.3 (2019-02-01) X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 31, 2019 at 09:42:42AM -0300, Marcelo Ricardo Leitner wrote: > On Thu, May 30, 2019 at 03:56:34PM -0400, Neil Horman wrote: > > On Thu, May 30, 2019 at 12:17:05PM -0300, Marcelo Ricardo Leitner wrote: > ... > > > --- a/net/sctp/sm_sideeffect.c > > > +++ b/net/sctp/sm_sideeffect.c > > > @@ -898,6 +898,11 @@ static void sctp_cmd_new_state(struct sctp_cmd_seq *cmds, > > > asoc->rto_initial; > > > } > > > > > > + if (sctp_state(asoc, ESTABLISHED)) { > > > + kfree(asoc->peer.cookie); > > > + asoc->peer.cookie = NULL; > > > + } > > > + > > Not sure I follow why this is needed. It doesn't hurt anything of course, but > > if we're freeing in sctp_association_free, we don't need to duplicate the > > operation here, do we? > > This one would be to avoid storing the cookie throughout the entire > association lifetime, as the cookie is only needed during the > handshake. > While the free in sctp_association_free will handle the freeing in > case the association never enters established state. > Ok, I see we do that with the peer_random and other allocated values as well when they are no longer needed, but ew, I hate freeing in multiple places like that. I'll fix this up on monday, but I wonder if we can't consolidate that somehow Neil > > > if (sctp_state(asoc, ESTABLISHED) || > > > sctp_state(asoc, CLOSED) || > > > sctp_state(asoc, SHUTDOWN_RECEIVED)) { > > > > > > Also untested, just sharing the idea. > > > > > > Marcelo > > > >