[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0065d875-a13c-c327-7d53-d376e235bf3d@suse.cz>
Date: Mon, 2 Jan 2023 12:37:57 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Takashi Iwai <tiwai@...e.de>, x86@...nel.org
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Baoquan He <bhe@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/kexec: Fix double-free of elf header buffer
On 11/22/22 12:51, Takashi Iwai wrote:
> The recent fix for memory leaks forgot to clear the error path that
> already does vfree() for the elf headers. This may result in a
> double-free.
>
> Drop the superfluous vfree() call at the error path of
> crash_load_segments().
>
> Fixes: b3e34a47f989 ("x86/kexec: fix memory leak of elf header buffer")
> Signed-off-by: Takashi Iwai <tiwai@...e.de>
Acked-by: Vlastimil Babka <vbabka@...e.cz>
> ---
> arch/x86/kernel/crash.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
> index 9730c88530fc..305514431f26 100644
> --- a/arch/x86/kernel/crash.c
> +++ b/arch/x86/kernel/crash.c
> @@ -401,10 +401,8 @@ int crash_load_segments(struct kimage *image)
> kbuf.buf_align = ELF_CORE_HEADER_ALIGN;
> kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
> ret = kexec_add_buffer(&kbuf);
> - if (ret) {
> - vfree((void *)image->elf_headers);
> + if (ret)
> return ret;
> - }
> image->elf_load_addr = kbuf.mem;
> pr_debug("Loaded ELF headers at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
> image->elf_load_addr, kbuf.bufsz, kbuf.memsz);
Powered by blists - more mailing lists