From patchwork Mon May 22 13:49:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250582 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 2237AC77B75 for ; Mon, 22 May 2023 13:50:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AEB4900005; Mon, 22 May 2023 09:50:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95F20900002; Mon, 22 May 2023 09:50:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 826ED900005; Mon, 22 May 2023 09:50:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 65BA9900002 for ; Mon, 22 May 2023 09:50:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 364BC40298 for ; Mon, 22 May 2023 13:50:45 +0000 (UTC) X-FDA: 80818026450.27.9593C09 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 53A0280014 for ; Mon, 22 May 2023 13:50:43 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XQXYK46i; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1684763443; 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=KE9n9iro3FTjdaHiFIooYMOpWcibwpM8czGND8V/VvE=; b=tnG2hlONA/qaMJw2uFWNLlTOcNr1dtq+YrNpYMcJBmqWeHirEFBH2rKog5yZwyNRXCdEj0 jG4w3F7Ew+8mp7erbVPVc1HF7rOSnp7Ce0vZZCOfdyB45UW9Mfeg9RVKItQ+1tB8kFr7YX RfifZKuxqsXB1rc7DsFCaNeK+WMoKZ4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684763443; a=rsa-sha256; cv=none; b=C2JPBzfEJ5O7r8emvnsD6pHTDFYlHYpU5yvjUpXD/dEqpCavlSAh445JOwyC54EHzPz7t5 ZWr3wvaPqrc4klHoDMSm2JABI4halvhAxkBJUDn/VfTcAVeGfp5VQsC5C97gIyw/K7axXZ e50dCpgJZUWwDfHmnUTXHNPNZACnC+A= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XQXYK46i; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1684763442; 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=KE9n9iro3FTjdaHiFIooYMOpWcibwpM8czGND8V/VvE=; b=XQXYK46iuTNWJyhhSTjY0nMxsdlbAOJhQpCCvPuU0xLmfFHyquBxj80n6Prhpwk/2Qypjn /Gc34AS85AXB9xDDHtlQ6aHccmV9JVdz7nDL32AUOEglr3yXHS4YopOojmJoMaNWbdj8xq tMUzB4rDEPShrdQUyJZgTA57buvNV+M= 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-451-ZA03jKiYMVa10ZeylKgdAQ-1; Mon, 22 May 2023 09:50:39 -0400 X-MC-Unique: ZA03jKiYMVa10ZeylKgdAQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C83D4802A55; Mon, 22 May 2023 13:50:33 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BE2940CFD45; Mon, 22 May 2023 13:50:31 +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 v22 02/31] splice: Make filemap_splice_read() check s_maxbytes Date: Mon, 22 May 2023 14:49:49 +0100 Message-Id: <20230522135018.2742245-3-dhowells@redhat.com> In-Reply-To: <20230522135018.2742245-1-dhowells@redhat.com> References: <20230522135018.2742245-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: zqc9hdnmbs9rpgkoshnmbkwnbzibozki X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 53A0280014 X-Rspam-User: X-HE-Tag: 1684763443-612940 X-HE-Meta: U2FsdGVkX1+s7bF4pQz5H/7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90/fScl32MkWfQBgq3YpIG7iMM4lrrPZp0ZFjyIfFep07FTLfVhQsHEKBLinNyjv5xfgbvr809vI8oslz1ph/buW2qUy+pK6DrbDPTSepE9rgzw933h1TVkKGqezDxJmJIDbMAsIw5OA9AJVx0hrM8PVIu3krkM4Cj8PlRl/ooWdVZzIItbjJ3Houh2sww09vwuPulnKXJOWctVvhVwXG78XGU0K9Ts3zqaHyZpQXLmXwO5sG8AhYbXscCRi19kHW1iB0vI5WvDl8A6Xg8OLm/YVYp1IGH6CfknojsFLUZ3m4LTC3CvRXk6XwboPvHr2t/kFbca10zOSne3oEj+p92Q+0 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 Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner 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 --- 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;