Received: by 10.223.185.116 with SMTP id b49csp2458461wrg; Thu, 15 Feb 2018 11:54:31 -0800 (PST) X-Google-Smtp-Source: AH8x2259JdczuNJnWaKhMwiakl561LYZFFyO8gTdtKYtqIYG66G7E8UsoHz5FzCFRMfxcA2S5GCZ X-Received: by 10.98.245.18 with SMTP id n18mr3593438pfh.25.1518724471035; Thu, 15 Feb 2018 11:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518724471; cv=none; d=google.com; s=arc-20160816; b=M3c0rJAUQyLhqM/UtzmcRRD/A0vcDAVBrigWjjW3k+z4JCnjfNPsy1CpUasgnaY92s HAA8k4ab5I3xIOIzRfh81/Vt5SCh8zT1WG/FsoEOZplFqpia9I7O69u4DvqUFK6x2ZNj DkHEYL6FWagcnSW1p8gqVZXGUCADKRfwbe634LegYwMgMMqEPSMIwn9VA/1GL9UoFh0S Ow7NqL5H9lR9SnYD9kTcBVpbTDwhTC8gc32J7uzQEQWwv5v97JmtF55JkpPJe7doANLB NDCLLr9JsdQU37MFYGhAu7Uxn6ZdqWIQZb9TEtzqeiGb42AE+JUwuyeg6Kmw+38kqrtO 34Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7tMwnhqgUsqDq6FBHsgKqDXm5aqxllz+nRJOEusGzaQ=; b=qQUqi19ip4uIb+3IS/7Er4Ar8vGWiHz9NssSzS5EFLlegLRyuNJMP4ZGw84/ONCoXH VJcn4HrNeol4QjW94bMpVqiUpJwE8thKbw5Se82yL3lzkCY8sd2Xp8CJ9O63unu8dWhh rj/7IVNgGSb8Hl2gZig4CF7VLc3ZC3uQd4YEtK6ly4PKlTK6UjbLk/zQqrQaHyE3ylL9 ujkgsCD7ETt5FjuEwX8A6fTN/9aC5AuLjuo9kdZetHmktuVYnYXzYHOIZzYvTq3tbOfg rv/Fy6PFYxt2po3D3FAdLTqAk4db6snFEYxdpIBazrpzGQPRG48/j7/rkdl9xyRxef64 euVg== ARC-Authentication-Results: i=1; mx.google.com; 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 j24si71326pga.711.2018.02.15.11.54.15; Thu, 15 Feb 2018 11:54:30 -0800 (PST) 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; 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 S1162188AbeBOPVu (ORCPT + 99 others); Thu, 15 Feb 2018 10:21:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:49226 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162138AbeBOPVr (ORCPT ); Thu, 15 Feb 2018 10:21:47 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D6B4BCA4; Thu, 15 Feb 2018 15:21:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li RongQing , Eric Dumazet , "David S. Miller" Subject: [PATCH 4.4 031/108] tcp: release sk_frag.page in tcp_disconnect Date: Thu, 15 Feb 2018 16:16:28 +0100 Message-Id: <20180215151226.765366399@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li RongQing [ Upstream commit 9b42d55a66d388e4dd5550107df051a9637564fc ] socket can be disconnected and gets transformed back to a listening socket, if sk_frag.page is not released, which will be cloned into a new socket by sk_clone_lock, but the reference count of this page is increased, lead to a use after free or double free issue Signed-off-by: Li RongQing Cc: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2276,6 +2276,12 @@ int tcp_disconnect(struct sock *sk, int WARN_ON(inet->inet_num && !icsk->icsk_bind_hash); + if (sk->sk_frag.page) { + put_page(sk->sk_frag.page); + sk->sk_frag.page = NULL; + sk->sk_frag.offset = 0; + } + sk->sk_error_report(sk); return err; }