Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4322324pxu; Mon, 12 Oct 2020 16:10:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRHcX631bMWiJH52hapBF8zk1ZGmStbKqPRMEvYCk3+Nqv2zmytgWmtS4HD6xTLkU4jMxK X-Received: by 2002:a17:906:685a:: with SMTP id a26mr31200479ejs.458.1602544239243; Mon, 12 Oct 2020 16:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602544239; cv=none; d=google.com; s=arc-20160816; b=Cyo88C7Yk99qv692V8fh2FonQfenAcAykQCB0SXkKq8ximCuvjsS/BSO+mVvzj5tni BCrg0IRX8Ho3CPbRzC96XxL1MRrNMLEP5FADwLz+cS5mPsBEHyh79nSyOQVdd1vmfht6 KPbt+QmA91z/15hLdxqjOnSTJNvNtvnGzxl8iEyFd7verBSJRoAIYKYymmImIv6ogK/6 ygKV9OpdSwDkpKDAPhlqtQIltcptUVTDf83hPjHsChoWvhrZt7FblSQsOphxJ944ee4D ZA2jnmkBdSULGSlZ1jVhSqU7GEdCIqyuPfiaG7ZYytTF2CkVqDaD+DTS1/L+Gz8wlONo 1L4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b8au6I7f7Rd89qCb7lfeCiAOejPxCnbRepfykRqtfoA=; b=tgRK35KfqYM8+ebwyPpIU9C8ghfsQg2nDGVA9V+qxhTDJ5Bz0oIcXwV0RTsP+QZ2je tdwMuTVk5WJqGcIRSPgdJScEA8csdWTaNxQD68PzJUNJ32L+MxTX26nNDdPlHuc5vWwx XFwkkDE5bfIzN7fan3mrweOhbMNVcDFkhG4uwSQtiXOEbDZ67fXHzpW8wCJDnpoArJ5u kecyvSenjBM1+aDO+qCr/o0NPkbyk028uH+5bJj1UkPv7H1v2s6gC3aEKPGS3UX32fJL rnjrzAcyT71gR5tCpuVMfyC6AyOXRRMtPJnTBbCh71QlzPnJIoNuSOM+l7a/DeUeCULt +aSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SRCXPKr+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oq26si13436127ejb.620.2020.10.12.16.10.16; Mon, 12 Oct 2020 16:10:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SRCXPKr+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731133AbgJLNmk (ORCPT + 99 others); Mon, 12 Oct 2020 09:42:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:46218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731083AbgJLNlh (ORCPT ); Mon, 12 Oct 2020 09:41:37 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 D247F221FE; Mon, 12 Oct 2020 13:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510092; bh=iO7A3UDABTT4fqsjuY546SAsDNwvLoYNDp0TNT7BO5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SRCXPKr+jZjqycN8vHDui4EghZsUpr3rRpEjxOEC5daIcmrNF5KdhejIXzjq9GJOE hUUgqbesk1RxhWaOzjthdjrZA0Pe72czX/4JcAJGRicUCFpE6/PgiGuHGGX2p23K99 Z2oJcWSF/tI+tHiX47b1WmnA/HDwUkPyU53qZ5Yw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Coly Li , Vasily Averin , "David S. Miller" Subject: [PATCH 5.4 36/85] tcp: use sendpage_ok() to detect misused .sendpage Date: Mon, 12 Oct 2020 15:26:59 +0200 Message-Id: <20201012132634.594653424@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coly Li commit cf83a17edeeb36195596d2dae060a7c381db35f1 upstream. commit a10674bf2406 ("tcp: detecting the misuse of .sendpage for Slab objects") adds the checks for Slab pages, but the pages don't have page_count are still missing from the check. Network layer's sendpage method is not designed to send page_count 0 pages neither, therefore both PageSlab() and page_count() should be both checked for the sending page. This is exactly what sendpage_ok() does. This patch uses sendpage_ok() in do_tcp_sendpages() to detect misused .sendpage, to make the code more robust. Fixes: a10674bf2406 ("tcp: detecting the misuse of .sendpage for Slab objects") Suggested-by: Eric Dumazet Signed-off-by: Coly Li Cc: Vasily Averin Cc: David S. Miller Cc: stable@vger.kernel.org Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -971,7 +971,8 @@ ssize_t do_tcp_sendpages(struct sock *sk long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); if (IS_ENABLED(CONFIG_DEBUG_VM) && - WARN_ONCE(PageSlab(page), "page must not be a Slab one")) + WARN_ONCE(!sendpage_ok(page), + "page must not be a Slab one and have page_count > 0")) return -EINVAL; /* Wait for a connection to finish. One exception is TCP Fast Open