Re: [PATCH v2 RESEND] fs: shorten I/O that would extend past the maximum file offset

From: Ding Feng

Date: Thu Dec 03 2026 - 00:20:28 EST


Hi Matteo,

I tested v2 RESEND on v7.4-rc5 (fe6ff8d5d), x86_64 under QEMU, on
tmpfs. It applies with offsets only. The test runs each call on the
unpatched and the patched kernel; "huge" is a sparse file of size
LLONG_MAX, "small" is 100 bytes, "mid" is 20 MiB, M is LLONG_MAX:

call rc5 patched
pread(huge, 4096, M - 100) EINVAL 100
read(huge, 4096) at M EINVAL 0
preadv2(small, 200, M - 50) EINVAL 0
readv(small, 200) at M EINVAL 0
pwrite(new file, 100, M - 10) EINVAL 10
pwrite(new file, 100, M) EINVAL EINVAL
writev(new file, 100) at M EINVAL EINVAL
splice(mid -> pipe, 0x7FFFFFFFFF000000,
off_in 16 MiB) EINVAL 65536
sendfile(/dev/null <- huge, 4096, M - 100) EINVAL 100
aio IOCB_CMD_PREAD(huge, 4096, M - 100) EINVAL 100
io_uring READ(huge, 4096, M - 100) EINVAL 100
io_uring WRITE(new file, 100, M - 10) EINVAL 10
read(/proc/self/mem, 100) at U64_MAX - 9 EOVERFLOW EIO

After the short pwrite the file size is LLONG_MAX. A write that starts
at LLONG_MAX still fails, and /proc/self/mem now gets EIO from
mem_rw() instead of EOVERFLOW, both as the commit message describes.

Tested-by: Ding Feng <dingf3ng@xxxxxxxxx>

Thanks,
Ding Feng