Received: by 10.223.176.5 with SMTP id f5csp725073wra; Fri, 9 Feb 2018 06:16:23 -0800 (PST) X-Google-Smtp-Source: AH8x224HgKW9DE/e2IOudMj+epIz6wiVpGE0CbLU0aW67L+eESAoO/3JYTqKeqpJy4lasVtPWnjG X-Received: by 10.99.50.66 with SMTP id y63mr1675395pgy.207.1518185783522; Fri, 09 Feb 2018 06:16:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518185783; cv=none; d=google.com; s=arc-20160816; b=HUQnP8vN2ikRAVfoTtvAZDQ31sHd5WYKgK+OOhm/BQHJGKIs2XFHPiJjejQixbA4Rm igd89B7Buu2pUipVktfe7eX1MgsuF7FM/Syyc08YHty3/5CTecKavz5r+wRnR7FMA3nE ydtNGfGE94R7DFaB3fxEjBculR4Z1himbRi5tbcZoSWWRMgtPMu0T22S1dnuVOeRrHqi kbNg/sWU2bZh36529RzGajRJoBlSuLpTfgamIikQAPwbJT0V8itIWRzACOX9XgKNGuHl D71sGI7NCXMlfe9uKCh1d7C6FmnIq3tYxktLMs9uwijcnQvdhsIkP/+VSKo1+HLL7FEh oTjA== 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=M9+ukb1DoEyGfD0JPBJ5NSLhypMch5NeRqRqvl3V10M=; b=dZ00o1+ycEaPgjd0q+0mf2hYMnzb9Hyu26MhleIf/havnMBp3MaWRgU+lwTJdE+ih2 C1A0bVar3jv0NtWkPEU3b4KOAiTMcmL2/ECet8jx36LRyRYXJsdb/9Cc0bIvcG/GUfVf 6DhoPceyPmze/qJnkTUnHPTL4w3Yly1rT9cN0imFGUN0NhY+GkQ6wBLUxyjwWQic0HHH 91P/Ka6b3VP3YsatPQr7nqMf7AVh+0Vhbk6zJ4jXreSZB+7jONVOv7DkQjhCGAYIr1yG OLS6q5fQ/11ulGM66eO6hlY2Jf6auzSie9uma6/hQRrERRffmSZGy0u+f1aDmgPb9alN B2FA== 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 h18si1648907pfi.167.2018.02.09.06.16.09; Fri, 09 Feb 2018 06:16:23 -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 S1752562AbeBINlV (ORCPT + 99 others); Fri, 9 Feb 2018 08:41:21 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:48484 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbeBINlR (ORCPT ); Fri, 9 Feb 2018 08:41:17 -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 568AE6C; Fri, 9 Feb 2018 13:41:16 +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.9 24/92] tcp: release sk_frag.page in tcp_disconnect Date: Fri, 9 Feb 2018 14:38:53 +0100 Message-Id: <20180209133933.007513827@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133931.211869118@linuxfoundation.org> References: <20180209133931.211869118@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.9-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 @@ -2316,6 +2316,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; }