Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp636999ybi; Thu, 30 May 2019 04:26:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHTCVKh7sURKZBS2QXD/fmuzYEj8z9NF8wu3P/TsBd3tcmXAElpofB1wakT4fysM+MHeeA X-Received: by 2002:a17:902:b407:: with SMTP id x7mr3286341plr.28.1559215592048; Thu, 30 May 2019 04:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559215592; cv=none; d=google.com; s=arc-20160816; b=EdoOtX6grkVJRwGGuHtlSkRZQfvYDEtYyLPoiS1bjW12Nw+rvWqOjLV9Fgo4+fiwyA cpxQ7nj2VIxsPUtb0VKcDxFI0N0PvH2GnuAtap/DGzPYqTcoDLDDRR0ZdUvRBQNt1fmf Xm4Om8ibPb9svpkcvv2mJI/8d/bazaxq115LVlwqGvuT1rIOpEFsMDCm3b1Wtx8V7ps6 tzdMdwXJXkqBKgv7u151QCsY/9t8YM8PsvKFUN5kIBum+BxCTil2Gmy15377lrF/JYiX 4KgnrIj+MbDCKHlvdeIaqS+m5XyXVwgcMxao4UMOAuwJmFj+Uu/pG08ODp3ByOgdFHrU cg8Q== 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=VN71JT5Z+C4lsCIS4HFPnl5mUWbotznoUy3DsS+C9v0=; b=arfue1Q22Kel/PEbtgCR4wl+k7iDNWs7/MKkGVBTSs7VwjCrGnFsP00A+7gb2a3QRt H25GjyDmQx203u2K544ZN6QMOQNu7YX2CpATnnE47OA6yGr2il8AWoWPB0zDjLnyflTT dXxHjYUyn/8WYW+UVfAHWG1GJRVDMVbxqepR6CR8/3wWa36yDoycnouTProDXuvLsJHU bq/rnCim3VpHEZyliumdrXJXItHSkq7PyKQ5cp+kxvUAt7Sa70pArIqAW5ZMKdoolKvt OFuQ3GMZvt1Pzk/aXC9TNqJL+XwF1qRFIz/Tl0ZZCdSIf6ZTX2EpFk/i41YL8iyeJf1d 3MdA== 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 d19si2880604pls.221.2019.05.30.04.26.16; Thu, 30 May 2019 04:26:32 -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 S1726933AbfE3LY6 (ORCPT + 99 others); Thu, 30 May 2019 07:24:58 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:36507 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbfE3LY6 (ORCPT ); Thu, 30 May 2019 07:24:58 -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 1hWJAr-0006YK-LB; Thu, 30 May 2019 07:24:52 -0400 Date: Thu, 30 May 2019 07:24:18 -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: <20190530112418.GB1966@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190529233757.GC3713@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 Wed, May 29, 2019 at 08:37:57PM -0300, Marcelo Ricardo Leitner wrote: > On Wed, May 29, 2019 at 03:07:09PM -0400, Neil Horman wrote: > > --- a/net/sctp/sm_make_chunk.c > > +++ b/net/sctp/sm_make_chunk.c > > @@ -2419,9 +2419,12 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, > > /* Copy cookie in case we need to resend COOKIE-ECHO. */ > > cookie = asoc->peer.cookie; > > if (cookie) { > > + if (asoc->peer.cookie_allocated) > > + kfree(cookie); > > asoc->peer.cookie = kmemdup(cookie, asoc->peer.cookie_len, gfp); > > if (!asoc->peer.cookie) > > goto clean_up; > > + asoc->peer.cookie_allocated=1; > > } > > > > /* RFC 2960 7.2.1 The initial value of ssthresh MAY be arbitrarily > > What if we kmemdup directly at sctp_process_param(), as it's done for > others already? Like SCTP_PARAM_RANDOM and SCTP_PARAM_HMAC_ALGO. I > don't see a reason for SCTP_PARAM_STATE_COOKIE to be different > here. This way it would be always allocated, and ready to be kfreed. > > We still need to free it after the handshake, btw. > Yeah, that makes sense, I'll give that a shot. Neil > Marcelo >