]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ext4: fix bounds check in check_xattrs() to prevent out-of-bounds access
authorDeepanshu Kartikey <kartikey406@gmail.com>
Sat, 28 Mar 2026 15:00:38 +0000 (20:30 +0530)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 10 Apr 2026 02:01:39 +0000 (22:01 -0400)
commiteceafc31ea7b42c984ece10d79d505c0bb6615d5
tree5a5d4bdf5c0c6fafef59983edcf5bc85b8ec2256
parent3f60efd65412dfe4ff33b376a983220ef74056b1
ext4: fix bounds check in check_xattrs() to prevent out-of-bounds access

The bounds check for the next xattr entry in check_xattrs() uses
(void *)next >= end, which allows next to point within sizeof(u32)
bytes of end. On the next loop iteration, IS_LAST_ENTRY() reads 4
bytes via *(__u32 *)(entry), which can overrun the valid xattr region.

For example, if next lands at end - 1, the check passes since
next < end, but IS_LAST_ENTRY() reads 4 bytes starting at end - 1,
accessing 3 bytes beyond the valid region.

Fix this by changing the check to (void *)next + sizeof(u32) > end,
ensuring there is always enough space for the IS_LAST_ENTRY() read
on the subsequent iteration.

Fixes: 3478c83cf26b ("ext4: improve xattr consistency checking and error reporting")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20260224231429.31361-1-kartikey406@gmail.com/T/
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Link: https://patch.msgid.link/20260328150038.349497-1-kartikey406@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/xattr.c