Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2972313rwd; Mon, 22 May 2023 07:02:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QqytDmncl9wW+nMSQuXr/mMTaOByNi6I7OMrD7n+bvjPgPjINdBD8EmYy3hauyUqrTQwo X-Received: by 2002:a05:6a20:914c:b0:100:6863:8be7 with SMTP id x12-20020a056a20914c00b0010068638be7mr12311072pzc.62.1684764133115; Mon, 22 May 2023 07:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684764133; cv=none; d=google.com; s=arc-20160816; b=mnALXUmJuMpjdycQXVhOO5rCzDTtACTWsrgJeLPlx3lbrNZkJeTALo7IJWk86osX2i OuITrhyigskn4oX3zpywYGYmiNUL4JSU0qYlbfBRvqdJC1gHBe5zC1qfss2zoQj+8dY/ uPLvftXtpEyS+7chx7+6SPJJE5D2ezp2pxU/DaySBdDGYZpluK4FZjRvee+R4fhActct Li/IsKztSxj8ukE/9+FNEVGvBb1yYaYwUllCmTOFW3xQ7/3y/fIO1GqaxvTnVQ3fmaD8 uOajb3P8kKof/hXKl9ysHDlRQdosZuLqh8wtWARpeKmEp6qxNMNLuLop/FBL+aUw7mpu xwXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KE9n9iro3FTjdaHiFIooYMOpWcibwpM8czGND8V/VvE=; b=ZQevrKSx2hJ3gPCTixOy6vr6u5n11MOz7HY1b1kxTuNwhwPB9wIGq9fvwWEY2S9/+x zVy5JVstgN2KoOOF8apLY5sqQp8UW4Z3J7URWT/ZrhJacb7agkuQ0y7B3w8Ihs83KEDA HhZJcq8qfkjZITQL/6KJbRwhcP0OZrCsNCjBOOAyU49/KJhjsOpkeviFHkNh2+Ux9CmH 2uqgF7Rp+kLS1gqHCy4tUDpk4Dxe2K+XxcR124ze05LBXq1j3yhjjoNZDPdhSDaMjgH+ TwZksFAA3BbqLJd1WJgQfjh2MOxfZOVYMWjJv5L4na2swFzTEIwERrBVdEbjJF6iLp93 whVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BvmHxlLd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g124-20020a636b82000000b005346d08547dsi4604154pgc.747.2023.05.22.07.01.30; Mon, 22 May 2023 07:02:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BvmHxlLd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233196AbjEVNwO (ORCPT + 99 others); Mon, 22 May 2023 09:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233825AbjEVNwE (ORCPT ); Mon, 22 May 2023 09:52:04 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC4F189 for ; Mon, 22 May 2023 06:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763445; 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=BvmHxlLdgWXqXER+NqXM0U6Dg5uND2wHKGJwwic1TZ2BLKkPGps+gYiWmDO1ybgvzk9i8G Oz9xHOzzUcbELCezevujIUNGunTKnZ3Hd4btyTpdUscu+clUhqOseYaabz8ssQ2Wzdaj5a d7gMy7K/t/zKbQ1vxpuoSu1UauQR44Y= 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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;