Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3818124ybi; Mon, 29 Jul 2019 13:13:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyB0Jz+kLc68Gvz3U9GodKD6qBw80iiqMJTJM/wFXgIZTbV/mfCihQ+QgRICt50ufsLM7DZ X-Received: by 2002:a17:902:968c:: with SMTP id n12mr117144093plp.59.1564431193906; Mon, 29 Jul 2019 13:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431193; cv=none; d=google.com; s=arc-20160816; b=ZnjFtoKynU1+NaTrmTAfP5VtjD5/1ZQ5kvctfZPe1yUih53Vnjn1VCGkuiu8vLrW7c v/d64GN2jS12ANU/Pdv0VF+4t9wNYgGuQlGyC7hx+iNwtmcKyNhnDjj8UuwKA695e1FU TEy8cnORNBd2zuPfwi/Co77MjX3aTtc/462ORzjUAWUDDlYh35meMEqVf1KlheVLfj6v NUk919GWt36Wqg3bAhPMAfoa6EDWN0FXePcpxDRgvZqWx13C7xslGrPlluRETzaKbcHu lJ+3rWRdzCKqNiyzwDAdE5XLb0gqXak+S4MQfXMLymFTtYeH75x6N5SOH5SHrfK77RJs 5IRQ== 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=3xnjPTBLFLM+qGNYqMe7ofKlzluzOuNjeNrkOQaIFJc=; b=XjUaT1XcKhEOcudewuHWxTeXRKzAh8jCKbvUC2P3JOi6cmC5HzH4+NrTiff05Un1sH TpMZI3KnJ6stSNpe0dajfdNiPz6xrqiEr3HMkTVJSSrLntKCHguHE9X+KuQd6O94PSS8 +fjcv4oGgeo/snxbvyHKCo2IICeK449qTlksBd6Wx4blsEll9nc2AGc8m5BzGrqv0oaz RbVsTKDgkwT10DE3ACZki7QLqs1fjWuAfSZIXpPgyduZN9C9WzcAuhIt4/XYw2TGYhaU V1uUqDJ4bVR5q8zk+3ri3qc8tgBNeUvV44gQ4AzpMrvcWqZZ1bhIECyR+tM2X5ZBIc0Q hTiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AzdpvB4u; 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 ck13si24499866pjb.47.2019.07.29.13.12.58; Mon, 29 Jul 2019 13:13:13 -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=AzdpvB4u; 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 S1730529AbfG2ULR (ORCPT + 99 others); Mon, 29 Jul 2019 16:11:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:47896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387748AbfG2Tdj (ORCPT ); Mon, 29 Jul 2019 15:33:39 -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 73F3721773; Mon, 29 Jul 2019 19:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428819; bh=QEj/HLs4qgcfXS9pAfCuX2BkTk9HK4xqAbKdsVSyGCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AzdpvB4uVkbv2Spv2xRwuZhESchNV/XgF5OvsS/KtQ6ZNta0XjvyQUHukRII+8+S1 PxzOvWyTbh/x0NVdu9FFOlCa+rf1t3weL6dVeCpbz+HfV9Y7iwNEjCl97+tHZRgC4n zZZrNfRHw1DH5QLMXsRIZv8/PKyO6OeOo9Vzum4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ralf Baechle , Cong Wang , "David S. Miller" , syzbot+622bdabb128acc33427d@syzkaller.appspotmail.com, syzbot+6eaef7158b19e3fec3a0@syzkaller.appspotmail.com, syzbot+9399c158fcc09b21d0d2@syzkaller.appspotmail.com, syzbot+a34e5f3d0300163f0c87@syzkaller.appspotmail.com Subject: [PATCH 4.14 197/293] netrom: hold sock when setting skb->destructor Date: Mon, 29 Jul 2019 21:21:28 +0200 Message-Id: <20190729190839.561909247@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 4638faac032756f7eab5524be7be56bee77e426b ] sock_efree() releases the sock refcnt, if we don't hold this refcnt when setting skb->destructor to it, the refcnt would not be balanced. This leads to several bug reports from syzbot. I have checked other users of sock_efree(), all of them hold the sock refcnt. Fixes: c8c8218ec5af ("netrom: fix a memory leak in nr_rx_frame()") Reported-and-tested-by: Reported-and-tested-by: Reported-and-tested-by: Reported-and-tested-by: Cc: Ralf Baechle Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/netrom/af_netrom.c | 1 + 1 file changed, 1 insertion(+) --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -969,6 +969,7 @@ int nr_rx_frame(struct sk_buff *skb, str window = skb->data[20]; + sock_hold(make); skb->sk = make; skb->destructor = sock_efree; make->sk_state = TCP_ESTABLISHED;