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

From: Christoph Hellwig

Date: Fri Dec 12 2025 - 01:16:56 EST


On Fri, Dec 12, 2025 at 07:05:10AM +0530, Deepanshu Kartikey wrote:
> keys_info_len = struct_size(keys_info, keys, read_keys.num_keys);
> - if (keys_info_len == SIZE_MAX)
> + if (keys_info_len == SIZE_MAX || keys_info_len > KMALLOC_MAX_SIZE)

Well, bother checks for sure are redundant. But maybe this is also
a good chance to pick a sane arbitrary limited instead of
KMALLOC_MAX_SIZE. And if that is above KMALLOC_MAX_SIZE, switch to
using kvzalloc.