From patchwork Sun Jul 9 11:09:13 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: 13305805 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 C44CEEB64DD for ; Sun, 9 Jul 2023 11:17:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7D736B0072; Sun, 9 Jul 2023 07:17:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B066F6B0074; Sun, 9 Jul 2023 07:17:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A6F36B0075; Sun, 9 Jul 2023 07:17:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8710A6B0072 for ; Sun, 9 Jul 2023 07:17:57 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2C5B7C013D for ; Sun, 9 Jul 2023 11:17:57 +0000 (UTC) X-FDA: 80991823794.08.435B032 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 419A640002 for ; Sun, 9 Jul 2023 11:17:55 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=ACG3eK7o; spf=pass (imf12.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688901475; 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=J1hpqFDoPHyvJsaHsC7WRs/Cz6GhxSVsxM7v/gwaCk8=; b=QbuxN0QPP10ABKKJ4uqn2r8OUp4yxQTA0BHyRxLjE+xb4tbEKWsvr7QbFe3W11FUUJQsUe cCD4K+71JLV4zS3bn80OpU/0cgHmdgQ5oHfwZ3Y/SMwtPaMTkQl1V+dcRmIi3vC0SPeCe/ kWkEoM0j5+ZZCkx4MXexnMxD6+onxRQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688901475; a=rsa-sha256; cv=none; b=73u1lqe2S8oPYKoyKjQStCCQio5RW4JakZRee+6Qjz9ZKVEAH7URKG8MZSZ8eB1D+K+pML jFohOdSqtS4mREpNnVlUw92A/MEzbTRptjxR3uZ0wt6rQPVzc0sdDsob5IDarXtG1uz15n fgKvuYxP/ATkgaJIH1uhrxw3EzaUxV0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=ACG3eK7o; spf=pass (imf12.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org 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 9389260BD6; Sun, 9 Jul 2023 11:17:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CEF3C433C7; Sun, 9 Jul 2023 11:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1688901472; bh=N4w+S4FTGNCBgNW4xGflCQ5AKTCHPtzcKBHhGcQ3hMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ACG3eK7okKZQm3Toik76Ae+3zsT3aWbD8ZGl5MWxpjO3Q06vKkKfgxFfPaZPxDo7n W5HdIrye0Md31gRMEn/aleAtX0Jx/aLpFN0jAoWn13gRG++1XP4hBq58WMPmYpm0gy QLPT8WP+HZd5fqdr3JEELcNrV/5I6a2CjcfsqlFQ= 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.3 005/431] splice: Fix filemap_splice_read() to use the correct inode Date: Sun, 9 Jul 2023 13:09:13 +0200 Message-ID: <20230709111451.235981246@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230709111451.101012554@linuxfoundation.org> References: <20230709111451.101012554@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Rspamd-Queue-Id: 419A640002 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 9oab3wbkb5d8x46qa7364u8mkbjud7ms X-HE-Tag: 1688901475-73361 X-HE-Meta: U2FsdGVkX18Hleh5CAHCxuORuAACUL/oy4h/L72EdBnkwKxTtqri2CCsqa/MHhY0BliPgILJIcgxFSNhIj/j21dfkFilhwUJJxxxd5ZKGDqPO0WMfovViSFrcw98c822xQeAtAjcBZZq/jObXykU9/p5ogR78k6SLjpKOYzGLI873VBHI9ORdT7UHL0JRQ72M+bjaGqJDd60a6rcixwIsswOlDLVbJ1p6WxogOTOeufuuRaXcbfDdx8oihKGmZAP5FhzNyNXndXVthhQESyEuA8riFsPH0UTNOmI1gtQ4Tq7DiXuNgr45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/JuMOk88yy6IQ0Sj2vB3dh4d52APCuAsRNBMmGneWdTi75XqaiIBoSIe0hFLaz7L1mlWYH9KWqKuwodKEc6r2q6c/ICdMyqrmN44/DzVdyTuW/HBb15hKNE/lb7Lp8Oy7vooT/kDQ6q166JsyPX+m7bgccLVjs0b5n8ZYIaStKsHYTme6MutllD/9y3VX9vBR5/2E4+OK02mug6I 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 2723104cc06a1..8f048e62279a2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2903,7 +2903,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; @@ -2919,7 +2919,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);