[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKbZUD01au=HoDe=yXSLtxJgYdivZccqqBfpmnmQ04R1Y1orvg@mail.gmail.com>
Date: Sun, 15 Oct 2023 21:35:26 +0100
From: Pedro Falcato <pedro.falcato@...il.com>
To: kasan-dev@...glegroups.com, Alexander Potapenko <glider@...gle.com>
Cc: Marco Elver <elver@...gle.com>, Dmitry Vyukov <dvyukov@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: kmsan: Panic on failure to allocate early boot metadata
On Sun, Oct 15, 2023 at 9:26 PM Pedro Falcato <pedro.falcato@...il.com> wrote:
>
> Given large enough allocations and a machine with low enough memory (i.e
> a default QEMU VM), it's entirely possible that
> kmsan_init_alloc_meta_for_range's shadow+origin allocation fails.
Ugh, forgot to run checkpatch.pl until it was too late :/
> Instead of eating a NULL deref kernel oops, check explicitly for memblock_alloc()
If there's no need for a v2, please wrap the above line and...
> failure and panic with a nice error message.
>
> Signed-off-by: Pedro Falcato <pedro.falcato@...il.com>
> ---
> mm/kmsan/shadow.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c
> index 87318f9170f..3dae3d9c0b3 100644
> --- a/mm/kmsan/shadow.c
> +++ b/mm/kmsan/shadow.c
> @@ -285,12 +285,18 @@ void __init kmsan_init_alloc_meta_for_range(void *start, void *end)
> size = PAGE_ALIGN((u64)end - (u64)start);
> shadow = memblock_alloc(size, PAGE_SIZE);
> origin = memblock_alloc(size, PAGE_SIZE);
> +
> + if (!shadow || !origin)
> + panic("%s: Failed to allocate metadata memory for early boot range "
> + "of size %llu",
unwrap this string like this:
"%s: Failed to allocate metadata memory for early boot range of size %llu",
Silly mistake...
--
Pedro
Powered by blists - more mailing lists