]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_io: fix mread with length 1 mod page size
authorEric Biggers <ebiggers@google.com>
Tue, 11 Jun 2024 18:29:28 +0000 (11:29 -0700)
committerCarlos Maiolino <cem@kernel.org>
Mon, 17 Jun 2024 11:50:56 +0000 (13:50 +0200)
commit7ea701ffc7cf306a903f2966519b3f5aedfb77ea
treee1ae17c096f86687687e582a760aae211b39fdde
parent7ccc7965ed53e82fb92d235ccf5e79bf6fa04009
xfs_io: fix mread with length 1 mod page size

Fix a weird bug in mread where if you passed it a length that was 1
modulo the page size, for example

        xfs_io -r file -c "mmap -r 0 8192" -c "mread -v 0 4097"

... it never reset its pointer into the buffer into which it copies the
data from the memory map.  This caused an out-of-bounds write, which
depending on the length passed could be very large and reliably
segfault.  Also nothing was printed, despite the use of -v option.

(I don't know if this case gets reached by any existing xfstest, but
presumably not.  I noticed it while working on a patch to an xfstest.)

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
io/mmap.c