Thread (5 messages) 5 messages, 3 authors, 2025-12-15

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

From: Stefan Hajnoczi <stefanha@redhat.com>
Date: 2025-12-15 14:21:29
Also in: lkml

On Sun, Dec 14, 2025 at 09:33:59PM -0800, Christoph Hellwig wrote:
On Fri, Dec 12, 2025 at 08:17:43PM +0530, Deepanshu Kartikey wrote:
quoted
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?
Yes, that's good. Thanks for looking into this, Deepanshu.

Stefan

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help