From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A554CC5B57D for ; Tue, 2 Jul 2019 08:15:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C0F7205ED for ; Tue, 2 Jul 2019 08:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562055329; bh=jIOQbsCP4X+3mrOpraffnVNqY8f0gWvNEEoEDdaJRt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=q0RYjPO+IDpikNKrZMr+eCeJ8Bd9u9bqE7TOkDcqu1T1EqnRf2gdibCZPcmq3eBlG rvO31zLZMFilpFpA90BuQTmVA6AEWNBzmkc27GEMwsfv8ansQvoepMDVPgUQwHbWE0 ZEZlJHHyg2/BiUIdXxioIRKD1Wim12fWnvFO3sQw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbfGBIP1 (ORCPT ); Tue, 2 Jul 2019 04:15:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:50648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727164AbfGBIEz (ORCPT ); Tue, 2 Jul 2019 04:04:55 -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 2D5F420659; Tue, 2 Jul 2019 08:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054694; bh=jIOQbsCP4X+3mrOpraffnVNqY8f0gWvNEEoEDdaJRt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxvUyvpHByVje9LmkQ2WBwt3pKC11e/VDsRcd3ZyKmH/0L0e85IpodulHin9h/ZD9 YeIb58WFdixCo+5tn3cwq+2StYHsdFvtYHxta8Pir9fByz7RzxNiwO2hG4tvwUu/tL 3Oh6J3dNMnRoKf39bBDOoNBgNsFrryIj+VuNc/y8= 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 5.1 38/55] sctp: change to hold sk after auth shkey is created successfully Date: Tue, 2 Jul 2019 10:01:46 +0200 Message-Id: <20190702080126.103992090@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.103022729@linuxfoundation.org> References: <20190702080124.103022729@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 @@ -133,10 +133,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); @@ -169,6 +165,10 @@ static struct sctp_endpoint *sctp_endpoi ep->prsctp_enable = net->sctp.prsctp_enable; ep->reconf_enable = net->sctp.reconf_enable; + /* Remember who we are attached to. */ + ep->base.sk = sk; + sock_hold(ep->base.sk); + return ep; nomem_shkey: