From: Stefan Hajnoczi <stefanha@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Deepanshu Kartikey <kartikey406@gmail.com>,
axboe@kernel.dk, 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: Mon, 15 Dec 2025 09:21:18 -0500 [thread overview]
Message-ID: <20251215142118.GA19970@fedora> (raw)
In-Reply-To: <aT-dxw-VSqXMQR_h@infradead.org>
[-- Attachment #1: Type: text/plain, Size: 833 bytes --]
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:
> > 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2025-12-15 14:21 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
2025-12-15 14:21 ` Stefan Hajnoczi [this message]
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=20251215142118.GA19970@fedora \
--to=stefanha@redhat.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=kartikey406@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.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;
as well as URLs for NNTP newsgroup(s).