From patchwork Sun Jul 16 19:37:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13314878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13747C00528 for ; Sun, 16 Jul 2023 19:53:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0C116B0072; Sun, 16 Jul 2023 15:53:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBC108D0002; Sun, 16 Jul 2023 15:53:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D82D38D0001; Sun, 16 Jul 2023 15:53:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C81366B0072 for ; Sun, 16 Jul 2023 15:53:41 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9904FC024A for ; Sun, 16 Jul 2023 19:53:41 +0000 (UTC) X-FDA: 81018525042.09.C31E5CE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 9912540003 for ; Sun, 16 Jul 2023 19:53:39 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=WlTeRr3n; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf07.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689537219; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BMopp5oCcWu7GNg2j9MiwSN5AX2U/Bgo5g8/CurCZxY=; b=yEceolxil8J2X3vr7wB59kHJExUQ1eZaZWUL2wJkbdpS9RsNyV30SmRPaNm9jYD1KcZQtx 18SmPKj5Bt2g4V3ppg851qTjbgGzHChMhBXJ6/vCArOIBwmsjk/2r+Gw8ULJCbfzqdXm+U 14EbfDYlWfAm+pd7sAm9uyFYQFow8rw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=WlTeRr3n; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf07.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689537219; a=rsa-sha256; cv=none; b=sbeX+KRZ+rynM6bVPozy+zRz+P2/YUS/u6K55RBBhnc8e0nghuWMNNj+IGygPyPUrwJrGU x1eylxCVEOTA4hOb+j6rEx8cOrndOml78UOxkD75S940eRaHTWw6rARytMPu83y+xDb5/c dmEGeTYjXC5aLE+f0Vz32JaIHhXaVD0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9098860EAE; Sun, 16 Jul 2023 19:53:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77CABC433C8; Sun, 16 Jul 2023 19:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689537218; bh=K5rHq1LfKc4VZBVAHSnPR42oWNHNTxIJfGEJlkEBi4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WlTeRr3nQnyKkp6WCG8HyBdjR4h29WNNlwSta4f1Cv3798vWcznKPgqckh5Oa+VqS HIJi3AgJQpAQk4zah9chWfRQAPPPAZ/0c5Hpwjhf8nZSYOv7k1JbqAfGTM1a4jm5Td MzGmapLYg8XK0CRjzryjo0oIW843j5w9/eMZm7EQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Howells , Christoph Hellwig , Christian Brauner , Steve French , Jens Axboe , Al Viro , David Hildenbrand , John Hubbard , linux-mm@kvack.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Sasha Levin Subject: [PATCH 6.4 018/800] splice: Fix filemap_splice_read() to use the correct inode Date: Sun, 16 Jul 2023 21:37:51 +0200 Message-ID: <20230716194949.527681049@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230716194949.099592437@linuxfoundation.org> References: <20230716194949.099592437@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9912540003 X-Stat-Signature: 3mkfcn48mt4wcuuhqb8ng11j9nrsc6ni X-HE-Tag: 1689537219-602163 X-HE-Meta: U2FsdGVkX1869T1/t6NH85F6RM1EWgrjzVVJIlTLPEaoX00A8M7l2rHt/iL1NEjXjgelSbrY7Vo/GUC2o2mham6+YRKbC3QfnPD3Yz8+wKgnPLuCZaxIozgHRrCKnsYc2WIDQuUCQH+X9z6AykbMmhTIX0WAHt3xVNV2P4MWpNpufSyrur9IuHkBN6C8HW3Kfikz95khSQeLsIh7qIiGxFMvazqXyW9I2z2DvP6sSIh0JqnlkiC+OGITtPQ8QB5adHfS6PafnsQAXUp6d+0GAt5892jRYTnxP3RNTNmEhVUwdl+TVWlFmgCHZf8aGga+c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ewnni9r1dBwuR/fMdWiMIthcB4nnNiCqt81iJGHu+GNW5fd7AOcS98gSuFMiv/pGVFDYbaQTUIBtDS4QFaWXBd8Kiqtm3Aql0T/NQV0s33SQNrIWGq/ONCavGATFT6evYB02AGcHBsbm70W8vLSydukZciczcynAzjD8xqcKGkuEVAvz6GtL6xfPuQF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: David Howells [ Upstream commit c37222082f23c456664d1c3182a714670ab8f9a4 ] Fix filemap_splice_read() to use file->f_mapping->host, not file->f_inode, as the source of the file size because in the case of a block device, file->f_inode points to the block-special file (which is typically 0 length) and not the backing store. Fixes: 07073eb01c5f ("splice: Add a func to do a splice from a buffered file without ITER_PIPE") Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Steve French cc: Jens Axboe cc: Al Viro cc: David Hildenbrand cc: John Hubbard cc: linux-mm@kvack.org cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/20230522135018.2742245-2-dhowells@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 83dda76d1fc36..8abce63b259c9 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2906,7 +2906,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, do { cond_resched(); - if (*ppos >= i_size_read(file_inode(in))) + if (*ppos >= i_size_read(in->f_mapping->host)) break; iocb.ki_pos = *ppos; @@ -2922,7 +2922,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, * part of the page is not copied back to userspace (unless * another truncate extends the file - this is desired though). */ - isize = i_size_read(file_inode(in)); + isize = i_size_read(in->f_mapping->host); if (unlikely(*ppos >= isize)) break; end_offset = min_t(loff_t, isize, *ppos + len);