Re: [PATCH v3] block: add allocation size check in blkdev_pr_read_keys()

From: Jens Axboe
Date: Wed Dec 17 2025 - 09:48:45 EST



On Wed, 17 Dec 2025 07:17:12 +0530, Deepanshu Kartikey wrote:
> 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.
>
> [...]

Applied, thanks!

[1/1] block: add allocation size check in blkdev_pr_read_keys()
commit: a58383fa45c706bda3bf4a1955c3a0327dbec7e7

Best regards,
--
Jens Axboe