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 1A0D8C61DA4 for ; Tue, 14 Feb 2023 13:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231932AbjBNNGM (ORCPT ); Tue, 14 Feb 2023 08:06:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229938AbjBNNGK (ORCPT ); Tue, 14 Feb 2023 08:06:10 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CA6523C7F for ; Tue, 14 Feb 2023 05:06:02 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id jg8so39886070ejc.6 for ; Tue, 14 Feb 2023 05:06:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=UO1S8iW9/QAKVzEJhMRyzNECLihlHvjUObjxxMYI9O0=; b=EHFPpiUbwjhpMXxUIF7LhqG6rIpi+UqGSBGeWDQmMdq/H/4cSj5dy+pWLbjn+5Q2PE 3Uu+8cgbrs8l1cedRkQIXA0oImCzK2Kua9ZjbNyB6hSMdCLJ6XuLOzwN/NXwmPLQ9Z/N VnyvAkJeiLtHgPm9ccQpnGJhDezr7ST2P6LuY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UO1S8iW9/QAKVzEJhMRyzNECLihlHvjUObjxxMYI9O0=; b=mnuswPP86qOsm8jrcygEpXZq4F9+2LF9YFVXw4AgjX8EMUWfTPqpxRBKD90ePJxOj9 w7ttffM3FpA8MmlipFIpJF9CmUtSjr005fdMeSBPXsdRRM+fX3VFSh33URtxthmRDyBd EHtIIleeFrXJtEUQ1b9W86SqWsGyu7gjnvBBHQPvHoJJo4vfCZuBMCxL5O8xN27p+QD2 nLaprGRuUWhGuc3rMFPnJNEAKepp8LRX8vbpYHYgHotoKoGopMkaZqXfTJ+Z6qdGlZ8f yZtRIa3p1GYMRbqXrulFIJ/LF/I1vCwbVd/5f+6wgSirUE9MmCezvuNJEbfSGWAa+hE0 AGtg== X-Gm-Message-State: AO0yUKU7LmfM4VRngltCPIXhrKYlkuOXbtvxjHzym/uomfM2tJDm9KSb Kgcz+0Nze77EJEjPnfKC/dhkCu1xXctFShQUs7ixUJJbUrjfK78x X-Google-Smtp-Source: AK7set+I/XMXzZKvwt68Wb9MWG1DTRZ//RvsjWH1cHJPqXhfYhA6+T3VMQPi9934Peu7job2YIQNxIo0BpMeuOgtl80= X-Received: by 2002:a17:907:1ddc:b0:878:790b:b7fd with SMTP id og28-20020a1709071ddc00b00878790bb7fdmr1259822ejc.14.1676379960856; Tue, 14 Feb 2023 05:06:00 -0800 (PST) MIME-Version: 1.0 References: <20230214083710.2547248-1-dhowells@redhat.com> <20230214083710.2547248-6-dhowells@redhat.com> In-Reply-To: <20230214083710.2547248-6-dhowells@redhat.com> From: Miklos Szeredi Date: Tue, 14 Feb 2023 14:05:49 +0100 Message-ID: Subject: Re: [PATCH v3 5/5] shmem, overlayfs, coda, tty, proc, kernfs, random: Fix splice-read To: David Howells Cc: Jens Axboe , Al Viro , Christoph Hellwig , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Daniel Golle , Guenter Roeck , Christoph Hellwig , John Hubbard , Hugh Dickins , Jan Harkes , Arnd Bergmann , Greg Kroah-Hartman , coda@cs.cmu.edu, codalist@coda.cs.cmu.edu, linux-unionfs@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 14 Feb 2023 at 09:38, David Howells wrote: > > The new filemap_splice_read() has an implicit expectation via > filemap_get_pages() that ->read_folio() exists if ->readahead() doesn't > fully populate the pagecache of the file it is reading from[1], potentially > leading to a jump to NULL if this doesn't exist. > > A filesystem or driver shouldn't suffer from this if: > > - It doesn't set ->splice_read() > - It implements ->read_folio() > - It implements its own ->splice_read() > > Note that some filesystems set generic_file_splice_read() and > generic_file_read_iter() but don't set ->read_folio(). g_f_read_iter() > will fall back to filemap_read_iter() which looks like it should suffer > from the same issue. > > Certain drivers, can just use direct_splice_read() rather than > generic_file_splice_read() as that creates an output buffer and then just > calls their ->read_iter() function: > > - random & urandom > - tty > - kernfs > - proc > - proc_namespace > > Stacked filesystems just need to pass the operation down a layer: > > - coda > - overlayfs > > And finally, there's shmem (used in tmpfs, ramfs, rootfs). This needs its > own splice-read implementation, based on filemap_splice_read(), but able to > paste in zero_page when there's a page missing. > > Fixes: d9722a475711 ("splice: Do splice read from a buffered file without using ITER_PIPE") The fixed commit is not upstream. In fact it seems to be on the same branch as this one. Please reorder the patches so that a Fixes tag is not needed. Thanks, Miklos