Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7147885ybi; Mon, 8 Jul 2019 15:36:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpe50fgVMlq/FALGp3lC4pDoNsX0lfSylhDbrxdy/js/CiciG5HjPm/ERy4R+rj1RmJCgT X-Received: by 2002:a17:90a:2525:: with SMTP id j34mr29398415pje.11.1562625374400; Mon, 08 Jul 2019 15:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625374; cv=none; d=google.com; s=arc-20160816; b=tsK8D4FKxwhZLhSpkzwieo0ZIISREk7NqobMZL7yAQHD+xjOQNF1J5z4W7+vl3TPaa HGRMpT5B6xs8fktEN4/Mxwg7lZCpzJTss9u85M1NrHb6BfwEj25+N4b3RW96dxJvV610 /6DI+B6QE3bUdn1fc8qcdvFXJyTgE1izJEJkLJ5xRKck/HZszlbKgWFDNAdST2JKP1QS LDfPWKh3hdWkV/c+0jQ1IDtBLljLXwt3oA5ZITrCJA3icJ7DWmW7znZc3vVzpFOo+WiY EhFdmd9AEDiqOEcCwIrRj7iGaZdYgeYIBWcM5AmiDbUzgrwP//ayd0DGpx5XsL75BqvL +Tjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RvuKeFQ7uJUq8ntCpmTigXWJWlgJlDnzE01fC84mTyU=; b=bO7r09LBQO9IKvuJ5m1t7IXdxH77XAMXk9fYdB3vhNmTyUylflkwVIvnsfBM/ApAk0 9GdCE1Fm2CnfyPSy2MefshlaMxYwx7G1wvq0Ok9zKc/+uOhMJFaFm3S3IejdtKSJojX2 Pr2TTJvdNo0dP3YKPq29EG55MM+tS2KETxlM9925Ahf9FK/Hdm/btiq23XmMAgklISQj WvC2Vjm34akx1pRUGSuCUPGhHIMp4Vf102chsuZQg2BXUDv50WVhEujQN9iD4C1a2u6h hfB51GiKLHwnlJWANZfDUgzu9yzL2yzed8AJDyGWXeZux7wBhJx39i08iTEKPNFt1weC IO5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tHFKlfur; 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 w22si715538pjn.55.2019.07.08.15.35.59; Mon, 08 Jul 2019 15:36:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b=tHFKlfur; 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 S2387691AbfGHPU6 (ORCPT + 99 others); Mon, 8 Jul 2019 11:20:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:46122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387656AbfGHPUv (ORCPT ); Mon, 8 Jul 2019 11:20:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC47A2182B; Mon, 8 Jul 2019 15:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599250; bh=lXgYJ88QjOuOoYufTSd5UBKHmsWzYrpuGVb1Luvt/P0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHFKlfurHW1qWXoR0GEVYkFz7WDLzEjTEr5d6r3suORi7KzEOljVfUgmwq+kAnNV3 6ad0vLDU1BTGVCWYXhT65uaeHjmEwVqamMBbxucr+BixB9LC8kuRnwEReWyYlRUXSm 3Dn5hbfA63uD0B/wNrFjz/temhJt9RJ8scaLNO4E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+afabda3890cc2f765041@syzkaller.appspotmail.com, syzbot+276ca1c77a19977c0130@syzkaller.appspotmail.com, Xin Long , Neil Horman , "David S. Miller" Subject: [PATCH 4.9 054/102] sctp: change to hold sk after auth shkey is created successfully Date: Mon, 8 Jul 2019 17:12:47 +0200 Message-Id: <20190708150529.248380860@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long [ Upstream commit 25bff6d5478b2a02368097015b7d8eb727c87e16 ] Now in sctp_endpoint_init(), it holds the sk then creates auth shkey. But when the creation fails, it doesn't release the sk, which causes a sk defcnf leak, Here to fix it by only holding the sk when auth shkey is created successfully. Fixes: a29a5bd4f5c3 ("[SCTP]: Implement SCTP-AUTH initializations.") Reported-by: syzbot+afabda3890cc2f765041@syzkaller.appspotmail.com Reported-by: syzbot+276ca1c77a19977c0130@syzkaller.appspotmail.com Signed-off-by: Xin Long Acked-by: Neil Horman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/endpointola.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -125,10 +125,6 @@ static struct sctp_endpoint *sctp_endpoi /* Initialize the bind addr area */ sctp_bind_addr_init(&ep->base.bind_addr, 0); - /* Remember who we are attached to. */ - ep->base.sk = sk; - sock_hold(ep->base.sk); - /* Create the lists of associations. */ INIT_LIST_HEAD(&ep->asocs); @@ -165,6 +161,10 @@ static struct sctp_endpoint *sctp_endpoi ep->auth_chunk_list = auth_chunks; ep->prsctp_enable = net->sctp.prsctp_enable; + /* Remember who we are attached to. */ + ep->base.sk = sk; + sock_hold(ep->base.sk); + return ep; nomem_hmacs: