From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BA61C636D7 for ; Fri, 17 Feb 2023 21:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbjBQVst (ORCPT ); Fri, 17 Feb 2023 16:48:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbjBQVsp (ORCPT ); Fri, 17 Feb 2023 16:48:45 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55E49EF9A for ; Fri, 17 Feb 2023 13:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676670473; h=from:from: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; bh=if/tW06TDxxLKgUq7/Etw5p2PggjEQkfj1fwjUBcfbU=; b=LxbQaXJVmrDug8DgtDlSA/MvWZs3+dR161aR4BHsWMhsPv9liCKBO8AteJXTsurtVRXwmO NJSff7iXnVkhMeux+Z2Lqkxz/1DaqNf4cFTt9CdUE6inskrRBFJld+xpFFIPMGm6yKph0c CWW1U0cNdWtleGgnKAlaXXoHZ/v2yAA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-80wKAcFcPWuJ9_HZUpt2Bw-1; Fri, 17 Feb 2023 16:47:47 -0500 X-MC-Unique: 80wKAcFcPWuJ9_HZUpt2Bw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 631B23815F7B; Fri, 17 Feb 2023 21:47:46 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1328F492C3E; Fri, 17 Feb 2023 21:47:43 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <87a61ckowk.fsf@oc8242746057.ibm.com> References: <87a61ckowk.fsf@oc8242746057.ibm.com> To: Alexander Egorenkov Cc: dhowells@redhat.com, axboe@kernel.dk, david@redhat.com, hch@infradead.org, hch@lst.de, hdanton@sina.com, jack@suse.cz, jgg@nvidia.com, jhubbard@nvidia.com, jlayton@kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, logang@deltatee.com, viro@zeniv.linux.org.uk, willy@infradead.org, Marc Hartmayer Subject: Re: [PATCH v14 08/17] splice: Do splice read from a file without using ITER_PIPE MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <732890.1676670463.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 17 Feb 2023 21:47:43 +0000 Message-ID: <732891.1676670463@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Does the attached fix the problem for you? The data being written into th= e pipe needs to be limited to the size of the file. David diff --git a/mm/filemap.c b/mm/filemap.c index c01bbcb9fa92..6362ac697a70 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2948,7 +2948,8 @@ ssize_t filemap_splice_read(struct file *in, loff_t = *ppos, if (writably_mapped) flush_dcache_folio(folio); = - n =3D splice_folio_into_pipe(pipe, folio, *ppos, len); + n =3D min_t(loff_t, len, isize - *ppos); + n =3D splice_folio_into_pipe(pipe, folio, *ppos, n); if (!n) goto out; len -=3D n;