From patchwork Sat May 20 00:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248983 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 D22E6C77B7F for ; Sat, 20 May 2023 00:01:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E316900006; Fri, 19 May 2023 20:01:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46C59900003; Fri, 19 May 2023 20:01:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30D0B900006; Fri, 19 May 2023 20:01:09 -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 221D2900003 for ; Fri, 19 May 2023 20:01:09 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F1595C0AFF for ; Sat, 20 May 2023 00:01:08 +0000 (UTC) X-FDA: 80808678216.24.B817400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 18A471C000D for ; Sat, 20 May 2023 00:01:06 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FFeMIcKJ; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684540867; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nJaiYO7hPfGCITlMv/e2fYDm8/jpubbHDQ4RMy5/oPM=; b=FfDyiqH74LQ5yLE+e0f3DYdB2GOuz+SCGlBsPfavPm0wOqYJxVD8aciHTT9W0YCu1Ohkyy TXO6LbdLJ5DPhBKt7EkndWd3HiC+OQKcQByfctTZrKKe7ajO1ebOCn2OBpCNj0+qCktYAk 6Ki3P4YHOZXHgDLOK2DwZPqBzCVUTfU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540867; a=rsa-sha256; cv=none; b=ZIydQTjkmX7xri+Ix2Uwhw0WEDPHQpRGVBpRov/4uwNLjG0JXcntOeO1m0tqZcdLjIGKur XZRGSRQWvM0EnGg2winxZg8MkXp0msymlZwq0lR5NBBhz2i+duYz1zuhwpJgNNLgUUF1LR eVenVfqSV9oY3z2P4zKHoNXYyY5uAwY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FFeMIcKJ; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nJaiYO7hPfGCITlMv/e2fYDm8/jpubbHDQ4RMy5/oPM=; b=FFeMIcKJTqZbZKKj5LAW89UiFZhjInYtbaZrjqvE+5wBf0tZIl7mZGg1iKtLt4DSl1qGN1 KpajmYgvgmsTJtsLaiLqfeG+XTkkn+nbyTOZ0AModhY+LIH1MMgDMtxIXdAoyt93l7PO+8 bjbVSGJQSgLz0Oou5kdxcjPoA0bpQsk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-gdX8HUEaPSKe1E3KxEDqow-1; Fri, 19 May 2023 20:01:00 -0400 X-MC-Unique: gdX8HUEaPSKe1E3KxEDqow-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C53B1185A78E; Sat, 20 May 2023 00:00:59 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B5751121314; Sat, 20 May 2023 00:00:57 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Steve French , John Hubbard Subject: [PATCH v21 02/30] splice: Make filemap_splice_read() check s_maxbytes Date: Sat, 20 May 2023 01:00:21 +0100 Message-Id: <20230520000049.2226926-3-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: 18A471C000D X-Rspam-User: X-Stat-Signature: a9kzop1n6iucozn9dqu6964ta7eujkda X-Rspamd-Server: rspam03 X-HE-Tag: 1684540866-244524 X-HE-Meta: U2FsdGVkX18eC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KReAEZMqQJIqbXSEENTMxHMhD7+oxFl+88v4G2EZewqQgtD7kbaCwV4ngSCaqgYo685aN8nqf3ho5InRPfcS6CPwgpptWHdEJoKw7ErG5tlwFIdL3vNrPorItLcOt64NVQMrWoHW4MInfw1MClXQoTN/myrOEH33kvfTqvUDGtrBlNJeFgrY2I9kB7aHwKcpiZJAN1MVlvpM5gI6alkeJv3Ou/+hUn6u/YOMACuMTOnb7gy9WjyrJ/NuJAyyfvOIJRmUQSrHShA/kh64P6gPnStMBuTKd+IZ4GOyg5iIdS82GtqOR1iAr58L/pLlFnAWtfLawMEiST 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: Make filemap_splice_read() check s_maxbytes analogously to filemap_read(). Signed-off-by: David Howells cc: Christoph Hellwig 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 Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner --- mm/filemap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index a2006936a6ae..0fcb0b80c2e2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -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;