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 36CC8C61DA4 for ; Tue, 14 Feb 2023 14:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231637AbjBNOBR (ORCPT ); Tue, 14 Feb 2023 09:01:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232529AbjBNOBN (ORCPT ); Tue, 14 Feb 2023 09:01:13 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5D0425E0D; Tue, 14 Feb 2023 06:00:38 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pRvqg-0004pq-28; Tue, 14 Feb 2023 14:59:58 +0100 Date: Tue, 14 Feb 2023 13:59:49 +0000 From: Daniel Golle To: Greg Kroah-Hartman Cc: David Howells , 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, Guenter Roeck , Christoph Hellwig , John Hubbard , Miklos Szeredi , Hugh Dickins , Jan Harkes , Arnd Bergmann , coda@cs.cmu.edu, codalist@coda.cs.cmu.edu, linux-unionfs@vger.kernel.org Subject: Re: [PATCH v3 5/5] shmem, overlayfs, coda, tty, proc, kernfs, random: Fix splice-read Message-ID: References: <20230214083710.2547248-1-dhowells@redhat.com> <20230214083710.2547248-6-dhowells@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 14, 2023 at 09:54:08AM +0100, Greg Kroah-Hartman wrote: > On Tue, Feb 14, 2023 at 08:37:10AM +0000, 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") > > Signed-off-by: David Howells > > cc: Daniel Golle > > cc: Guenter Roeck > > cc: Christoph Hellwig > > cc: Jens Axboe > > cc: Al Viro > > cc: John Hubbard > > cc: David Hildenbrand > > cc: Matthew Wilcox > > cc: Miklos Szeredi > > cc: Hugh Dickins > > cc: Jan Harkes > > cc: Arnd Bergmann > > cc: Greg Kroah-Hartman > > cc: coda@cs.cmu.edu > > cc: codalist@coda.cs.cmu.edu > > cc: linux-unionfs@vger.kernel.org > > cc: linux-block@vger.kernel.org > > cc: linux-fsdevel@vger.kernel.org > > cc: linux-mm@kvack.org > > Link: https://lore.kernel.org/r/Y+pdHFFTk1TTEBsO@makrotopia.org/ [1] > > --- > > Acked-by: Greg Kroah-Hartman Confirming that the above indeed fixes the NULL pointer bug. Tested-by: Daniel Golle