splice: Make filemap_splice_read() check s_maxbytes
authorDavid Howells <dhowells@redhat.com>
Mon, 22 May 2023 13:49:49 +0000 (14:49 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 24 May 2023 14:42:15 +0000 (08:42 -0600)
Make filemap_splice_read() check s_maxbytes analogously to filemap_read().

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
cc: Steve French <stfrench@microsoft.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: David Hildenbrand <david@redhat.com>
cc: John Hubbard <jhubbard@nvidia.com>
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-3-dhowells@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
mm/filemap.c

index a2006936a6ae20ea50ed9e01bb54a85a2f7f029d..0fcb0b80c2e23035da27c58f0d85354b4d4cce07 100644 (file)
@@ -2887,6 +2887,9 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
        bool writably_mapped;
        int i, error = 0;
 
+       if (unlikely(*ppos >= in->f_mapping->host->i_sb->s_maxbytes))
+               return 0;
+
        init_sync_kiocb(&iocb, in);
        iocb.ki_pos = *ppos;