Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1034895ybi; Fri, 2 Aug 2019 08:17:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBpXtIB4YEdM1PcO6+Pov4vmq1+qipRbz3okBgZn0064cbN9jA4iDgEZ7m3n6H7hgKjoAO X-Received: by 2002:a17:902:6847:: with SMTP id f7mr129231255pln.311.1564759035660; Fri, 02 Aug 2019 08:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564759035; cv=none; d=google.com; s=arc-20160816; b=oe4U+rPDAgbAPIn31du3WxqOd1s88g8Pb59+SBKEdQ6xUCdIzWeHY61SmiM61UPSjh wHZHPEmUlH0ZKfosZhSo51ElI1ryYARSAxviQGZQH60/0nm6BNCJnrfbb6WMJip2Rj6Q KNbBFGXqMIt1q3KaZjtbYe59/+SG8f3oGOjuG2xz4ayRTXe17JC74LBYwj9POrxMLBH2 Tjjux1YNM30qISY09w1c8rTXcyaCfZLib6EhS8V+UktsPGd3pHiFk0j+gJs17t3/Qdbc M8e7BMQ0TEKh69qxhtWkLyZNvl+AzmspZLQXBD3CPAbWTKIcgTF9Xjea+FW0qJJBu3c2 W9wQ== 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=4hwk5W2LxFQn4x8h0DR56g6pKz36EsDDY9qTsQyfhRc=; b=XxpQ+LG/i/hCaDNjxSncxpbBUoFv1zqTyjK1SJTozx14hymePeSOSrd6x738Tou5zp 9SxkyZfdS4fT0gwLkEO43PgpLCLeKigWIfgkMmYHbNMAj+dlG7GlvLLfCH/GgNTGexI8 jRNjmDr9PGGCVkNxTMovASm1Fh21NQFZ1gEExNRM67fydNMkapiM3OJStA74HMaPr0uM SRv6nbg6LNSieu9SYFauEfNtftEFqk1JVMnAxzqSkzEG+/6J4CKRa4M56Qy9tzVXsAZC JSTabm+ciU7ej0oowQJRy0qxAtg9K0/HrVz3bNU/q/42g4oBorCXOjcB3ySpNI8lxSxr /UOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVAFoGws; 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 l14si37058056pgh.205.2019.08.02.08.17.00; Fri, 02 Aug 2019 08:17:15 -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=BVAFoGws; 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 S2391494AbfHBJeN (ORCPT + 99 others); Fri, 2 Aug 2019 05:34:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:33932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390206AbfHBJeM (ORCPT ); Fri, 2 Aug 2019 05:34:12 -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 BDAD421773; Fri, 2 Aug 2019 09:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738451; bh=t+dt9i0XkcotkLFFiOBjf8HzBorm0ZgOFiq+RG5jY10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVAFoGws6aWrsvSoTFiFsyyC4F5nW3hppDac+GY9puSU/bmNbRH1XWnFqs1T/GWlR JWOZcIf61CgjPHF5Lij1O9BHfBcRgX2VzgXVbrxTJPX0Y8fLfoX/vZRBHbT9Yld6G3 JWOUhqmazt9EbXqqo1XykZ4TORgtM6C/RwUL2TvQ= 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.4 094/158] netrom: hold sock when setting skb->destructor Date: Fri, 2 Aug 2019 11:28:35 +0200 Message-Id: <20190802092223.511536567@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@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 @@ -968,6 +968,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;