Re: [PATCH] fs: fix overflow check in rw_verify_area()
From: Matteo Croce
Date: Fri Nov 20 2026 - 10:15:24 EST
Il giorno ven 20 nov 2026 alle ore 06:15 Ding Feng
<dingf3ng@xxxxxxxxx> ha scritto:
>
> Hi Matteo,
>
> On Wed, 24 Dec 2025 at 00:28, Matteo Croce wrote:
> > Following a discussion on the coreutils mailing list[1] I think that
> > this should be fixed differently.
> > I'll be back with a v2.
>
> This is still present in v7.4-rc3 (65e4fd942). On a 100-byte tmpfs
> file, a read that starts below LLONG_MAX but would end past it fails
> instead of returning 0 at end of file:
>
> preadv2(fd, 200 bytes, pos = LLONG_MAX - 50) = -1 EINVAL
> preadv2(fd, 50 bytes, pos = LLONG_MAX - 50) = 0
>
> sendfile() with *offset near LLONG_MAX fails the same way.
>
> Are you still planning a v2?
>
Hi Ding,
I think that the only solution is to create an helper
(rw_clamp_count?) which clamps the value and use it with
iov_iter_truncate().
I'll prepare a v2 soon.
Regards,
--
per aspera ad upstream