The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	axboe@kernel.dk, stefanha@redhat.com, martin.petersen@oracle.com,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+660d079d90f8a1baf54d@syzkaller.appspotmail.com
Subject: Re: [PATCH] block: add allocation size check in blkdev_pr_read_keys()
Date: Sun, 14 Dec 2025 21:33:59 -0800	[thread overview]
Message-ID: <aT-dxw-VSqXMQR_h@infradead.org> (raw)
In-Reply-To: <CADhLXY57aFmNB1v4TG2YxhOQL1+_02KkWpB3fEsn8t1GiFqdrg@mail.gmail.com>

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?

  reply	other threads:[~2025-12-15  5:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12  1:35 [PATCH] block: add allocation size check in blkdev_pr_read_keys() Deepanshu Kartikey
2025-12-12  6:16 ` Christoph Hellwig
2025-12-12 14:47   ` Deepanshu Kartikey
2025-12-15  5:33     ` Christoph Hellwig [this message]
2025-12-15 14:21       ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aT-dxw-VSqXMQR_h@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=kartikey406@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stefanha@redhat.com \
    --cc=syzbot+660d079d90f8a1baf54d@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox