Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3051361ybi; Tue, 2 Jul 2019 01:10:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoyiCLKkOxfSuxlF3QFfhQQVZ/5aLDi4JgNKCojoxOZyn4UjUzCMpSxMvz2yQVbl4+DKQd X-Received: by 2002:a63:5c1c:: with SMTP id q28mr28761861pgb.288.1562055021862; Tue, 02 Jul 2019 01:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055021; cv=none; d=google.com; s=arc-20160816; b=aEueFEI7slGg5wPuu+LZuq2HqFYNDNu1nqrp+jKtqAa3TGAWaloK1FLEzE++p23hgw vtORW9LJ1ggY6B+FzuI5+Lxw5dttnB1fa8wKwgv2nXa3r/o+u+DX8nhH7mTrobHcsjMv 54uX0cW56ITe4b3qPe/1WwhqmJ8V121TTJ3835ROpuNW84cP8kTTRlMdzQnyzxhBLe+6 v6g9U1eqjCfKBOEJhEahKykybfxqUeGFQ7IvO4BLZOs7PaViu+P9BVVzPW7uVfqGYwXb NTkI8DAVbSKE+XlndWexAIhWLmey91UHapbCcqO5zhkxdVYRdchcjDsrzQpSu+r+KjZJ lVaQ== 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=RM+gQNLjUGjpyDcM/3xojxBBJLS/FwQcpynZSBSS4VA=; b=A9ltT//n9KmJ+f6mG8YlOac/rr6RW8FqngF2sykr8n9WeiPWfb36ZvfbniYGcbYQIt jgp5RovrSHO4Bw73LHO4fmqmvxiPzN/2OSQLAOwg3BDUxLt5UWttqMD6ny63XwYsYAgF Ig3PiHy1dk7Udj9xzkvr3oRkvORHJ/PXQuAuoj0O/VngeIdGJXE3RcqEfZxMX1hhokSi 0LF5QBzvY77Ksz50atwNiKXNGSTSEylFgiDQ3MGIx8zMqvrk79RphTM7uwbhadebGbUQ i99TNG6fqJhJGjohrLXRxEX+7O5zqnHIMCKQfDTEnE0ithYdDY4I1w3yXiex4d9yXeYI lIBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bj7g+eTn; 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 x1si1645722pju.84.2019.07.02.01.10.07; Tue, 02 Jul 2019 01:10:21 -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=bj7g+eTn; 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 S1727790AbfGBIHp (ORCPT + 99 others); Tue, 2 Jul 2019 04:07:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:55064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728312AbfGBIHn (ORCPT ); Tue, 2 Jul 2019 04:07:43 -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 0371021479; Tue, 2 Jul 2019 08:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054862; bh=nHuwhUTRAxfjXPVHa1/B3FzGKUEmmVuofCaXCYoxoko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bj7g+eTnm6HZ/JTG1fzoYbzdKzoDZHp0yC+du++pSzVvl4Gs3l33MnAHW1iYrW59S /RmJqi5HVxRkojAdEV3E/lFHb1yr9GKMIGpXZ9MwIy106LjtN1wsu7ImiL3ebvDyhP x1HXv+HOjShzbuaiKvwCP1vVVzf+1qDNZd3SgBaY= 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.19 57/72] sctp: change to hold sk after auth shkey is created successfully Date: Tue, 2 Jul 2019 10:01:58 +0200 Message-Id: <20190702080127.559912786@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@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); @@ -167,6 +163,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_hmacs: