Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4321976pxu; Mon, 12 Oct 2020 16:10:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzywThP/fYTdt7IL39KsTp+HhaHfhFoAp4zrEGKfDaazv9uCQmGxg+eIdVDJtyKaKV4aIXs X-Received: by 2002:a17:906:7857:: with SMTP id p23mr30461085ejm.61.1602544200611; Mon, 12 Oct 2020 16:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602544200; cv=none; d=google.com; s=arc-20160816; b=qM0Jl55JyF/UttN3YT3qL5mvG3ILpaev3ed53tVP32EGZs42LfWVpdujKhOJ23fuTI 9uUXkRIs1dFIfUop/xA7DEwg67dlslxfq2CMdSDCHJsnli3i/X1fLKgYp3Y955Q+OGjV +1soCN5TgRhne+uML9lV3OofzBV9WliM5Qn4FoYZyFZC+f+xB9Ji2KCpquoojihg7kGk 1TBBd2f17k12tkYQB3FwST5n+twS8T3KzUl3sTYBWJIi1G1/32HN8GSO/wrM7I+4zXCS d0OqV5WQyAfjVUzgjWy9becWToRKi+pEtzxeyI0zGsdeH1nUBDzb3GTFqkt2dcEmLVTB MnPg== 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=MTmUsCamgwOs5vdr77rVM+6Z7R9rq0TguLm6/945uvE=; b=idTGVp5orz7ncFvEPcluPKxIJiTcVlvulZvbqVhI6eQh6xNXLkHLHkaCmWKAtdi4WB THsRaet1L2fqvzZPqDmCY2FKkZ5c/oiJoAbjkZGZWtT8QHFNs2a42dm+n083eY6GXVqw mYcGrfzYoNlUYlSLR3Ma+KKFQOYgNt22fC4t5yqCSh4sTku3WR2WKub0ekHrggi0j1Ei RWWzMLuF6WOWnN1VwQIEr+5kqrAp0NDwPNXnbS1Gnr7s95bNXcZMncien3mbL4TEuw4J YsxCFhys1SxNQzRhm1P76GNsiVkSvjawvJXGuv+eghqX2M8CBVgHxJ4h+JP4WTYRXZqX yEpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I5p+6HGa; 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 u23si13049938ejj.163.2020.10.12.16.09.38; Mon, 12 Oct 2020 16:10:00 -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=I5p+6HGa; 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 S1730923AbgJLNmi (ORCPT + 99 others); Mon, 12 Oct 2020 09:42:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:46220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731090AbgJLNlh (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 168482222C; Mon, 12 Oct 2020 13:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510094; bh=P+J3iYdLRe/4gnQUT2CTlAkEiy7G0U67pId7UtyfoC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5p+6HGa/oz3obYGIOkRAt3LRdEuBGTf+UTZBm3MdpYfuMh19lgJ+3skyagp88HZT yylgYjBGz6VWTK9vvVZDy8Z+xn1ujDEg4PfA5vLIEpMDVyegeNuw4MLZaHcRRrg11C h334BNpR+ZZ5N6WTH/jn/k4Hxg8hNhTHp40Dj3Cc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Chaitanya Kulkarni , Christoph Hellwig , Hannes Reinecke , Jan Kara , Jens Axboe , Mikhail Skorzhinskii , Philipp Reisner , Sagi Grimberg , Vlastimil Babka , "David S. Miller" Subject: [PATCH 5.4 37/85] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage() Date: Mon, 12 Oct 2020 15:27:00 +0200 Message-Id: <20201012132634.639060575@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 7d4194abfc4de13a2663c7fee6891de8360f7a52 upstream. Currently nvme_tcp_try_send_data() doesn't use kernel_sendpage() to send slab pages. But for pages allocated by __get_free_pages() without __GFP_COMP, which also have refcount as 0, they are still sent by kernel_sendpage() to remote end, this is problematic. The new introduced helper sendpage_ok() checks both PageSlab tag and page_count counter, and returns true if the checking page is OK to be sent by kernel_sendpage(). This patch fixes the page checking issue of nvme_tcp_try_send_data() with sendpage_ok(). If sendpage_ok() returns true, send this page by kernel_sendpage(), otherwise use sock_no_sendpage to handle this page. Signed-off-by: Coly Li Cc: Chaitanya Kulkarni Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Jan Kara Cc: Jens Axboe Cc: Mikhail Skorzhinskii Cc: Philipp Reisner Cc: Sagi Grimberg Cc: Vlastimil Babka Cc: stable@vger.kernel.org Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/tcp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -861,12 +861,11 @@ static int nvme_tcp_try_send_data(struct else flags |= MSG_MORE; - /* can't zcopy slab pages */ - if (unlikely(PageSlab(page))) { - ret = sock_no_sendpage(queue->sock, page, offset, len, + if (sendpage_ok(page)) { + ret = kernel_sendpage(queue->sock, page, offset, len, flags); } else { - ret = kernel_sendpage(queue->sock, page, offset, len, + ret = sock_no_sendpage(queue->sock, page, offset, len, flags); } if (ret <= 0)