Re: [PATCH] regset: use vmalloc() for regset_get_alloc()

From: Al Viro
Date: Thu Feb 01 2024 - 20:23:18 EST


On Thu, Feb 01, 2024 at 05:12:03PM -0800, Douglas Anderson wrote:
> While browsing through ChromeOS crash reports, I found one with an
> allocation failure that looked like this:

> An order 7 allocation is (1 << 7) contiguous pages, or 512K. It's not
> a surprise that this allocation failed on a system that's been running
> for a while.

> if (size > regset->n * regset->size)
> size = regset->n * regset->size;
> if (!p) {
> - to_free = p = kzalloc(size, GFP_KERNEL);
> + to_free = p = vmalloc(size);

What the hell? Which regset could have lead to that?
It would need to have the total size of register in excess of
256K. Seriously, which regset is that about? Note that we
have just made sure that size is not greater than that product.
size is unsigned int, so it's not as if a negative value passed
to function could get through that test only to be interpreted
as large positive later...

Details, please.