Re: [PATCH] block: add allocation size check in blkdev_pr_read_keys()
From: Christoph Hellwig <hch@infradead.org>
Date: 2025-12-15 05:34:02
Also in:
lkml
From: Christoph Hellwig <hch@infradead.org>
Date: 2025-12-15 05:34:02
Also in:
lkml
On Fri, Dec 12, 2025 at 08:17:43PM +0530, Deepanshu Kartikey wrote:
How about limiting num_keys to 64K (1u << 16)? In practice, PR keys are used for shared storage coordination and typical deployments have only a handful of hosts, so this should be more than enough for any realistic use case. With a bounded num_keys, the SIZE_MAX check becomes unnecessary, so I've removed it. Also switched to kvzalloc/kvfree to handle larger allocations gracefully. Something like below: +/* Limit the number of keys to prevent excessive memory allocation */ +#define PR_KEYS_MAX_NUM (1u << 16)
Looks reasonable to me. Stefan?