Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3787221ybi; Mon, 29 Jul 2019 12:36:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzy+Z4wYgXRaMyWNkarHKoKgVtMooHHMwMvvbtS26jKyw2NVKVPRiA2PuBNKSbogu28bt9A X-Received: by 2002:a17:902:8b82:: with SMTP id ay2mr68711900plb.164.1564429012711; Mon, 29 Jul 2019 12:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429012; cv=none; d=google.com; s=arc-20160816; b=NNnIwpo5ZmRY+yFouTNjN8+feFio6Z3Y0H6Um9AEUcXJ0K5r+2Ze5hqSnThkRKp2mt IdjPx0erWliypn/d9635whSnRG8aL8AgmnvyEes5ElBGzJxz5GwmsVEfPz5zFAsBL4A1 XQ9EWWD+byKpm+VoMb6rwoa5fztpOMrOh2/sDtsKFbny8R5bvflpjXXzIU+6d6zbXzMi VRTrudjXACdJGPwvmMUJPl5WyREtQw+DUfMX2cnGlBorQ6r7qPLGgiptYoD2lROsA2fI BeJCB5UYLKLoHMU+aZyw9VDEaf9rEDTS50LK08hZdWbarPxVh4I9UwN8ZkPylRusLDwX AjJA== 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=D/L5m3nI+AsHXJ4gZ8x67BuiramubbWAKzBvQiQ2UQM=; b=dGVx0CxtUCOYI0DKmn/nueQPKJ+tsMkCHmGIL94Cujdw68RmnwXhlaH6igChCul/lV WLHjTnmP4d2KTgLgDBscoTCnsedkXGElfjHeJgoDEq8JuYFMXBFbUW3eGYsxlvS2/swz InzYk9+kORQ42ShtAt/DT9g7AakfNbMfawqJBDyaGLIULhtWrQFknhIPmkcSSsFdkJ2k dPp8oF2zh/pHT5b2epswB8Crg8NgQOKRUG1gaVMZz+1EAhMTIpFm18F7vqyc3fMTkk1V 0IiafXwEB7N9RNSh/JJ6gqqbV9Jt/f+ditMbPmbwrmfF2X07YKXiopy3c6DIvfmRSZJK tWLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pZbVSYS1; 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 v20si27152493pgb.182.2019.07.29.12.36.38; Mon, 29 Jul 2019 12:36:52 -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=pZbVSYS1; 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 S1729597AbfG2Tdn (ORCPT + 99 others); Mon, 29 Jul 2019 15:33:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:47830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387604AbfG2Tdg (ORCPT ); Mon, 29 Jul 2019 15:33:36 -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 E66F621773; Mon, 29 Jul 2019 19:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428816; bh=6E5EdRJFvwwKHTg6u4GGDRI6rGEUkE2S1UcB+Lhht64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZbVSYS1j499uu8rlH9GyT2u1k7uh5AQKpAWQ2cyfOI5GaErvWi44frzaB+KY92lz dvMYUrj+w4QGQ5K38t3IFK9fTsfGgpc0MhI4QJgVF0GJCA6OvHR9hCoaPF6F4Zc3a4 5sjnZXJNY1SAA98eM8l5CMmgOXb8RUxpzb1zo4Nc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d6636a36d3c34bd88938@syzkaller.appspotmail.com, Cong Wang , "David S. Miller" Subject: [PATCH 4.14 196/293] netrom: fix a memory leak in nr_rx_frame() Date: Mon, 29 Jul 2019 21:21:27 +0200 Message-Id: <20190729190839.483361877@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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: Cong Wang [ Upstream commit c8c8218ec5af5d2598381883acbefbf604e56b5e ] When the skb is associated with a new sock, just assigning it to skb->sk is not sufficient, we have to set its destructor to free the sock properly too. Reported-by: syzbot+d6636a36d3c34bd88938@syzkaller.appspotmail.com Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/netrom/af_netrom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -871,7 +871,7 @@ int nr_rx_frame(struct sk_buff *skb, str unsigned short frametype, flags, window, timeout; int ret; - skb->sk = NULL; /* Initially we don't know who it's for */ + skb_orphan(skb); /* * skb->data points to the netrom frame start @@ -970,6 +970,7 @@ int nr_rx_frame(struct sk_buff *skb, str window = skb->data[20]; skb->sk = make; + skb->destructor = sock_efree; make->sk_state = TCP_ESTABLISHED; /* Fill in his circuit details */