Received: by 10.223.176.5 with SMTP id f5csp694251wra; Fri, 9 Feb 2018 05:49:42 -0800 (PST) X-Google-Smtp-Source: AH8x226tlUc5iTBByrb69WtzUqCnw+IMWBV0Ftw18UvYy7VYCDja5FFWH6WKJIoFayNJlepeeZna X-Received: by 2002:a17:902:1746:: with SMTP id i64-v6mr2614836pli.53.1518184182893; Fri, 09 Feb 2018 05:49:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518184182; cv=none; d=google.com; s=arc-20160816; b=oa9SlRhaE5nYcS8MvWLH28z7zs2EdtTRqQCBKkbiz8llLRykCDaUsnQXibh3LQED5t emBtntbDxww3mm6LhPCT5sIt6kxyDsGjga50f2Sf5nWchQ4uc2OmztCfbJISXSVLfSZC QnHPAiBUEULik9C3jL6dPE9nwByGWS3gk4eStHGehuo9sPe7NAiXQYGcmxEIncqsKcHY x7Ith+x0Z48Tgi7s0s+7zvLazJdYDD1QpKgImKTxgFDRrVRlPRRAocDOyeCmGnwPB+lO 78B5eRw46N/Yzx/kQIaVcb03ZR5Dc8Qo6GHtaGq6E1XmljMO6FmturIOz3WEPm95VAzF Wp0A== 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=7rbFDwZPEzXwr49GjubqOF2705EUwBP7P0Y5j3lbGSI=; b=OBDkfqNcSiUKnQ0JQCrYrRev438gQrUAluwUuTbPgLjfKwgWCq1oyFUC2Zq45hjdEu SbNiV1MiriObksmA70k7zECPxDnqzLulK67nS3M+tC8K5CNDe4PgWf2m86e95aVfL9FA 3BMcE+9RbTcm7ncqhdLDWNLHvsh/fHNIG7UoHn/wkfMU5w2vamLN09UI4X7kuwEW7U8m tAAtv7/9lYmruB3Bvi9+V+bDsvvgUu6LSAXOuAo2lm01iYkTybCvCC7aHNgL4khDyxsz Pzke1UtWieqAqE6aVIfettZN88SNY0c3oP1G3I/9sJoHp9XS7m7Tqc77mYPu5HilIrW+ 5Uew== 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 r7si1732304pfh.174.2018.02.09.05.49.29; Fri, 09 Feb 2018 05:49:42 -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 S1753942AbeBINrK (ORCPT + 99 others); Fri, 9 Feb 2018 08:47:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53574 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753604AbeBINrE (ORCPT ); Fri, 9 Feb 2018 08:47:04 -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 910A0E71; Fri, 9 Feb 2018 13:47:03 +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.15 06/23] tcp: release sk_frag.page in tcp_disconnect Date: Fri, 9 Feb 2018 14:40:04 +0100 Message-Id: <20180209133938.708757960@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133938.366024920@linuxfoundation.org> References: <20180209133938.366024920@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.15-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 @@ -2434,6 +2434,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; }