mirror-linux/include/uapi
Deepanshu Kartikey a58383fa45 block: add allocation size check in blkdev_pr_read_keys()
blkdev_pr_read_keys() takes num_keys from userspace and uses it to
calculate the allocation size for keys_info via struct_size(). While
there is a check for SIZE_MAX (integer overflow), there is no upper
bound validation on the allocation size itself.

A malicious or buggy userspace can pass a large num_keys value that
doesn't trigger overflow but still results in an excessive allocation
attempt, causing a warning in the page allocator when the order exceeds
MAX_PAGE_ORDER.

Fix this by introducing PR_KEYS_MAX to limit the number of keys to
a sane value. This makes the SIZE_MAX check redundant, so remove it.
Also switch to kvzalloc/kvfree to handle larger allocations gracefully.

Fixes: 22a1ffea5f ("block: add IOC_PR_READ_KEYS ioctl")
Tested-by: syzbot+660d079d90f8a1baf54d@syzkaller.appspotmail.com
Reported-by: syzbot+660d079d90f8a1baf54d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=660d079d90f8a1baf54d
Link: https://lore.kernel.org/all/20251212013510.3576091-1-kartikey406@gmail.com/T/ [v1]
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2025-12-17 07:35:22 -07:00
..
asm-generic vfs-6.19-rc1.folio 2025-12-01 10:26:38 -08:00
cxl
drm drm: define NVIDIA DRM format modifiers for GB20x 2025-11-06 11:01:45 +10:00
fwctl
linux block: add allocation size check in blkdev_pr_read_keys() 2025-12-17 07:35:22 -07:00
misc Char/Misc/IIO/Binder changes for 6.18-rc1 2025-10-04 16:26:32 -07:00
mtd
rdma RDMA/irdma: Add SRQ support 2025-09-18 04:48:46 -04:00
regulator
scsi scsi: fc: Avoid -Wflex-array-member-not-at-end warnings 2025-08-30 21:42:19 -04:00
sound ALSA: compress: document 'chan_map' member in snd_dec_opus 2025-09-28 08:29:03 +02:00
video
xen
Kbuild