Skip to content

Commit 29d650f

Browse files
author
Darrick J. Wong
committed
xfs: reject crazy array sizes being fed to XFS_IOC_GETBMAP*
Syzbot tripped over the following complaint from the kernel: WARNING: CPU: 2 PID: 15402 at mm/util.c:597 kvmalloc_node+0x11e/0x125 mm/util.c:597 While trying to run XFS_IOC_GETBMAP against the following structure: struct getbmap fubar = { .bmv_count = 0x22dae649, }; Obviously, this is a crazy huge value since the next thing that the ioctl would do is allocate 37GB of memory. This is enough to make kvmalloc mad, but isn't large enough to trip the validation functions. In other words, I'm fussing with checks that were **already sufficient** because that's easier than dealing with 644 internal bug reports. Yes, that's right, six hundred and forty-four. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Allison Henderson <allison.henderson@oracle.com> Reviewed-by: Catherine Hoang <catherine.hoang@oracle.com>
1 parent e783362 commit 29d650f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/xfs/xfs_ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ xfs_ioc_getbmap(
14641464

14651465
if (bmx.bmv_count < 2)
14661466
return -EINVAL;
1467-
if (bmx.bmv_count > ULONG_MAX / recsize)
1467+
if (bmx.bmv_count >= INT_MAX / recsize)
14681468
return -ENOMEM;
14691469

14701470
buf = kvcalloc(bmx.bmv_count, sizeof(*buf), GFP_KERNEL);

0 commit comments

Comments
 (0)