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=-6.8 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=ham 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 48754C606BD for ; Mon, 8 Jul 2019 15:49:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10F0621479 for ; Mon, 8 Jul 2019 15:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562600981; bh=+GwPzEOpw5S18r0S/X3gJhyirxtrHyUFBlolXQlgkqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=m/OX0WV7eEqfIBgMLIABNLmx4Us9qiUB+3yyB3Kd3fiucDtbzNFbx3emVTlEmw7kN F1gpSCLu5jpBWNbBzPxRl4ycvy7igYYx5oOw4Ex90PlMlvra5MIj7tCjKMagU4UeZW NV5bLtxxnv56jWRyABsx6XDbhWRo4U6xjU1IN3nk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388513AbfGHPtk (ORCPT ); Mon, 8 Jul 2019 11:49:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:39394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730447AbfGHPQZ (ORCPT ); Mon, 8 Jul 2019 11:16:25 -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 3B24E216FD; Mon, 8 Jul 2019 15:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562598984; bh=+GwPzEOpw5S18r0S/X3gJhyirxtrHyUFBlolXQlgkqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZjHCKq3E1/Gwg2MCm+XZCZ8YNXOcDLh5a7VhPsKR61nmoFFsP+RFn7FsvWfgzEJhd DhprHsSYtSttCAFc+nEG4GCLtwr4pMERn8ApTGuQfBV2TypFWkcAxJmt7X/Gf1jOrp pjyL2ahAp5T1L0VHULcOgpmPfXuzDYkFuR9Ds1mA= 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.4 40/73] sctp: change to hold sk after auth shkey is created successfully Date: Mon, 8 Jul 2019 17:12:50 +0200 Message-Id: <20190708150523.470576582@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150513.136580595@linuxfoundation.org> References: <20190708150513.136580595@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 @@ -126,10 +126,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_hmacs_list = auth_hmacs; ep->auth_chunk_list = auth_chunks; + /* Remember who we are attached to. */ + ep->base.sk = sk; + sock_hold(ep->base.sk); + return ep; nomem_hmacs: