From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796295221; b=aTtJISHT/234VL5aGvGGA0PwRUgN5BM0nAVZjy+sqTHeRDJy70f7Bv9DkcaBH4mISVLr idQzbFwBG185JguX+fiswQWupYkjjOBTzHsdeLg1xN0sZ+/+RRiCQcuTG8pUxtArBPpcw hZqO5LnGN+FCOfmGQfSLa9STs4MDpjvknZybkTN+ENnJC0EQLO33OhqV18A0EceYGkXWF /aFjKKBBI3z4p0njKChXYw2lQkg2r3gFvsZP6QkkrPlPRdDTc/QWYuTSeoEnlI2+Pei77 bu4qiKDvcTs95pMi0TFGhllouw9ykE09/M+Qij/zS9bPkkDQSNjlNIYOZK3yulcwrYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796295221; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=CxKm6zqn1UcYkZGA2K9y+SmgYidjRSCGlCftjccqFAc=; b=p1OQKimP+s/CfrKQqQBHgNMxVClX7YHeswTl8aSVtLZC/SHoR8Jtj6csSAydz4aSSx7y 4/nd7owjqDex4gqlgb6vc0TsdXKpCHQuk1vOTjjQ9uS6zTJR496r1Ytaoruc67Fpq7eMO FH/VgVVHBxmm4bBgIlFc47NONT9w1y0PdJJbeJmvmoPG9yxpD+2CE28A/+u3cNYcdP9vm g4bmvDtl/n7lXxxOsmmioSZXRCc6NUkGgddF+TA8bJ67HyEzHOz6G0UsnbZ1EgSBCCMtn esU5F+36NiD+bILDNQQoxwaz3qK3HpZj31B/jk6lkCTAbW1AcFrpbuMHeZe5eBSVqzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="a+N0/QBg"; arc=none smtp.remote-ip=209.85.216.49 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DDD1606A332 for ; Thu, 3 Dec 2026 10:53:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6DDD1606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=a+N0/QBg Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-3b51a9606e8so5312708a91.3 for ; Thu, 03 Dec 2026 02:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796295220; x=1796900020; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=CxKm6zqn1UcYkZGA2K9y+SmgYidjRSCGlCftjccqFAc=; b=a+N0/QBg2JX7qwqWQW+flGtwKC7/JtD2QuxYReQwOpxSxW49z4KrUH8kw/a0swNDED HG8B6DtC44KFtTTLNYLFliLHwPLknje6Q40l2l/2Ot5Kmo1OpP3Z3eyOdLw2oaZ/6I1s uYTxcOVX/Dga/EIvaizl/lzZt38VJFwbeDIdZl381Aum1YuHtK6jT45aLBwoq/M5/hqD BCihoYpG4ynqWjDkUKq6Cae1oejMl89b0N/v+X2jHeSwwkxj0cZjWUr2dJTsuG8B0Gel gZU5Ny2vMnNs009qABKzOk/adeNjs9YyPdJg510RcWDzdgtWOsn0g7DpOF1q+PV3UfIy OQvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796295220; x=1796900020; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CxKm6zqn1UcYkZGA2K9y+SmgYidjRSCGlCftjccqFAc=; b=PBVFdAm0EzegWRbd49Rr/2Md/yHHY1PBXE0TKrFjfWAc4nWyBoyakOjGaMIpAni3Ww 2ILTVibJh3cqrbHUD210rEnkTEQNXTnfh/8Eie149LkjzKgPvggrUntaWTXhyTFDmNvz u8eDzBWMGN/1PZmLGhRfW2MFuJOg7v7ySFsGHfAaV9HA9W3rELi4D5OKkJPWfL2cVMXj Gb6UlWBUf801zw1l+Tm1wNueSV30u4osieOCwbkyD7km8GBy6/h23Xp32aOzxLa3/syT Q87vtmY5zD19cnVDZFkdtrQnAJRrVNEU4VkPxq4aLTJGGcyp1S3THBKXVzBDE6u5IVVF 7U6g== X-Forwarded-Encrypted: i=1; AL+hErH4w4TIhTl3DT9eABx4nAvgAh/jjN1+0AQ9rdU9NlZOARldTxcA2NuWo54AlNuCVEO6oJIlMwjhnBJD@vger.kernel.org X-Gm-Message-State: APuU4Z/PURqWz3CERi8Hpp5Oc6icSFlaAcrWjTFsCXzOU166xdn8ezg7 FkUkA/IyPYznvaxE5AV60/iuyXJqmu0vDmpMmpsNJII59jKxktf9R6AC X-Gm-Gg: AZFdTZc7pjEnasoGPauQrNiwYGUVAnEyZHJ/MUMqDIcqKGZXnYLVyrnDulat58R8Ygv 9rjNgyy3yStvxMJtFv7oLpSsZx2lpUskoR5HCydER+uKuYsOhic+IA4SoDHf32pz4dQVlvxAz8n kvPPm9lfqK7Xl8PfMbg2myjGTI1/M4+tUZ09KJeFJnfYmlFH62oI5eWsnohcrIRfLjakU1IwH68 jMrOjHZ38uACpC7MCnfyjGN8FV7aMCPsk//FG9HYFUnHj9K1+w0YztSxo79nOQwpBcxSwCkI7Ya tjqBy9A/59u8DxlREHRQyMMBqYqwlRKnPdvUE0kxViUoAbLKWHdoKk+6mh+Ov0zdXWUMeiGNVBk wPdsXuz72ZtMVPiR+wXDs7zjSLgvatA0h/jKqoVIw0H4VlIZWDT/bVnwDjK3wLkIzA/hCwrrQPM wlBWjf61ldhAK94G9ButZAAUjxaKxGDk8H9xP1N3gacuwB6s4Yy4sB98Kpmr0KyTj64Q4RXJJWE YKIcAePyO5fuULc84ck1BtB0GjtedRgTCQRCaRdsGu4+Sbdz2eMJEqt1q9S0EMvJcaXl6RbXChK efHpscuCRZzoLsNt2j7nVS3cI3yfifKwC18USyg= X-Received: by 2002:a17:90b:3891:b0:3b4:127a:2bc2 with SMTP id 98e67ed59e1d1-3b41c8d9bfamr42943711a91.14.1796295219545; Thu, 03 Dec 2026 02:53:39 -0800 (PST) Received: from localhost.localdomain ([64.118.140.61]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5c784e74esm3862724a91.6.2026.12.03.02.53.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 02:53:39 -0800 (PST) From: Ding Feng To: fstests@vger.kernel.org Cc: zlang@kernel.org, hch@infradead.org, jack@suse.cz, dennylin0707@gmail.com, linux-ext4@vger.kernel.org Subject: [PATCH] generic: test that insert range respects RLIMIT_FSIZE Date: Thu, 3 Dec 2026 18:53:30 +0800 Message-ID: <20261203105330.65937-1-dingf3ng@gmail.com> X-Mailer: git-send-email 2.55.0 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit FALLOC_FL_INSERT_RANGE grows a file by the length of the range, so it must fail with EFBIG once the new size would exceed RLIMIT_FSIZE, as truncate and extending fallocate do (generic/394, generic/228). XFS refuses such an insert; ext4 checks only s_maxbytes and grows the file past the limit. Start from a 2-block file: inserting one block under a 2-block limit must fail and leave the size unchanged, and the same insert under a 3-block limit must succeed. Suggested-by: Christoph Hellwig Signed-off-by: Ding Feng --- Tested on v7.4-rc5, x86_64 under QEMU: ext4 fails: the insert under the 2-block limit succeeds, size 3 ext4 with "ext4: check RLIMIT_FSIZE in insert range" [1] passes xfs passes, with and without that patch [1] https://lore.kernel.org/all/20261116185810.82581-1-dennylin0707@gmail.com/ tests/generic/810 | 46 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/810.out | 6 ++++++ 2 files changed, 52 insertions(+) create mode 100755 tests/generic/810 create mode 100644 tests/generic/810.out diff --git a/tests/generic/810 b/tests/generic/810 new file mode 100755 index 00000000..25f5ece4 --- /dev/null +++ b/tests/generic/810 @@ -0,0 +1,46 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Ding Feng. All Rights Reserved. +# +# FS QA Test No. 810 +# +# Check that FALLOC_FL_INSERT_RANGE respects RLIMIT_FSIZE: an insert range +# grows the file by its length, so it must fail with EFBIG when the new size +# exceeds the limit, and leave the file size unchanged. +# +. ./common/preamble +_begin_fstest auto quick insert prealloc + +_fixed_by_fs_commit ext4 xxxxxxxxxxxx \ + "ext4: check RLIMIT_FSIZE in insert range" + +_require_test +_require_xfs_io_command "finsert" + +file=$TEST_DIR/$seq.file + +# Insert range works in whole file blocks, and ulimit -f in 1 KiB units. +unit=$(_get_file_block_size $TEST_DIR) +[ $unit -lt 4096 ] && unit=4096 + +# Run "finsert 0 $unit" on $file under an FSIZE limit of $1 units. SIGXFSZ is +# ignored so that the call fails with EFBIG instead of killing xfs_io. +insert_under_limit() +{ + bash -c "ulimit -f $(($1 * unit / 1024)); trap '' SIGXFSZ; \ + $XFS_IO_PROG -c 'finsert 0 $unit' $file" + echo "size: $(($(stat -c %s $file) / unit)) units" +} + +rm -f $file +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((2 * unit))" $file >> $seqres.full + +echo "Insert one unit into a 2-unit file under a 2-unit limit. This should fail." +insert_under_limit 2 + +echo "Insert one unit into a 2-unit file under a 3-unit limit. This should succeed." +insert_under_limit 3 + +# success, all done +status=0 +exit diff --git a/tests/generic/810.out b/tests/generic/810.out new file mode 100644 index 00000000..7542704d --- /dev/null +++ b/tests/generic/810.out @@ -0,0 +1,6 @@ +QA output created by 810 +Insert one unit into a 2-unit file under a 2-unit limit. This should fail. +fallocate: File too large +size: 2 units +Insert one unit into a 2-unit file under a 3-unit limit. This should succeed. +size: 3 units -- 2.55.0