lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aUEOWFY3d3vsA1EI@infradead.org>
Date: Mon, 15 Dec 2025 23:46:32 -0800
From: Christoph Hellwig <hch@...radead.org>
To: Deepanshu Kartikey <kartikey406@...il.com>
Cc: axboe@...nel.dk, martin.petersen@...cle.com, stefanha@...hat.com,
	linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
	syzbot+660d079d90f8a1baf54d@...kaller.appspotmail.com
Subject: Re: [PATCH v2] block: add allocation size check in
 blkdev_pr_read_keys()

On Tue, Dec 16, 2025 at 10:41:47AM +0530, Deepanshu Kartikey wrote:
> blkdev_pr_read_keys() takes num_keys from userspace and uses it to
> calculate the allocation size for keys_info via struct_size(). While
> there is a check for SIZE_MAX (integer overflow), there is no upper
> bound validation on the allocation size itself.
> 
> A malicious or buggy userspace can pass a large num_keys value that
> doesn't trigger overflow but still results in an excessive allocation
> attempt, causing a warning in the page allocator when the order exceeds
> MAX_PAGE_ORDER.
> 
> Fix this by introducing PR_KEYS_MAX_NUM to limit the number of keys to
> a sane value. This makes the SIZE_MAX check redundant, so remove it.
> Also switch to kvzalloc/kvfree to handle larger allocations gracefully.
> 
> Fixes: 22a1ffea5f80 ("block: add IOC_PR_READ_KEYS ioctl")
> Tested-by: syzbot+660d079d90f8a1baf54d@...kaller.appspotmail.com
> Reported-by: syzbot+660d079d90f8a1baf54d@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=660d079d90f8a1baf54d
> Link: https://lore.kernel.org/all/20251212013510.3576091-1-kartikey406@gmail.com/T/ [v1]
> Signed-off-by: Deepanshu Kartikey <kartikey406@...il.com>
> ---
> v2:
>   - Added PR_KEYS_MAX_NUM (64K) limit instead of checking KMALLOC_MAX_SIZE
>   - Removed redundant SIZE_MAX check
>   - Switched to kvzalloc/kvfree
> ---
>  block/ioctl.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/block/ioctl.c b/block/ioctl.c
> index 61feed686418..98c4c7b9e7fe 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -18,6 +18,8 @@
>  #include "blk.h"
>  #include "blk-crypto-internal.h"
>  
> +#define PR_KEYS_MAX_NUM		(1u << 16)

I think _NUM is redundant here.  Also this should probably go into
the uapi header.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ