From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, dovmurik@linux.ibm.com
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
Jordan Justen <jordan.l.justen@intel.com>,
James Bottomley <jejb@linux.ibm.com>,
Tobin Feldman-Fitzthum <tobin@linux.ibm.com>
Subject: Re: [edk2-devel] [PATCH v3 2/5] OvmfPkg/X86QemuLoadImageLib: plug cmdline blob leak on success
Date: Tue, 29 Jun 2021 13:18:45 +0200 [thread overview]
Message-ID: <364b6a96-3d06-f478-7e8c-4e46936e6aad@redhat.com> (raw)
In-Reply-To: <20210628105110.379951-3-dovmurik@linux.ibm.com>
On 06/28/21 12:51, Dov Murik wrote:
> When QemuLoadKernelImage() ends successfully, the command-line blob is
> not freed, even though it is not used elsewhere (its content is already
> copied to KernelLoadedImage->LoadOptions). The memory leak bug was
> introduced in commit 7c47d89003a6 ("OvmfPkg: implement QEMU loader
> library for X86 with legacy fallback", 2020-03-05).
>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: James Bottomley <jejb@linux.ibm.com>
> Cc: Tobin Feldman-Fitzthum <tobin@linux.ibm.com>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Fixes: 7c47d89003a6f8f7f6f0ce8ca7d3e87c630d14cc
> Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
> ---
> OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
> index 1177582ab051..6b1e7e649014 100644
> --- a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
> +++ b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
> @@ -446,14 +446,16 @@ QemuLoadKernelImage (
> }
>
> *ImageHandle = KernelImageHandle;
> - return EFI_SUCCESS;
> + Status = EFI_SUCCESS;
>
> FreeCommandLine:
> if (CommandLineSize > 0) {
> FreePool (CommandLine);
> }
> UnloadImage:
> - gBS->UnloadImage (KernelImageHandle);
> + if (EFI_ERROR (Status)) {
> + gBS->UnloadImage (KernelImageHandle);
> + }
>
> return Status;
> }
>
Tested-by: Laszlo Ersek <lersek@redhat.com>
next prev parent reply other threads:[~2021-06-29 11:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 10:51 [PATCH v3 0/5] OvmfPkg: Use QemuKernelLoaderFs to read cmdline/initrd Dov Murik
2021-06-28 10:51 ` [PATCH v3 1/5] OvmfPkg/GenericQemuLoadImageLib: plug cmdline blob leak on success Dov Murik
2021-06-29 9:27 ` [edk2-devel] " Laszlo Ersek
2021-06-29 10:23 ` Laszlo Ersek
2021-06-28 10:51 ` [PATCH v3 2/5] OvmfPkg/X86QemuLoadImageLib: " Dov Murik
2021-06-29 9:31 ` [edk2-devel] " Laszlo Ersek
2021-06-29 11:18 ` Laszlo Ersek [this message]
2021-06-28 10:51 ` [PATCH v3 3/5] Revert "OvmfPkg/QemuKernelLoaderFsDxe: don't expose kernel command line" Dov Murik
2021-06-29 9:32 ` [edk2-devel] " Laszlo Ersek
2021-06-29 10:23 ` Laszlo Ersek
2021-06-28 10:51 ` [PATCH v3 4/5] OvmfPkg/GenericQemuLoadImageLib: Read cmdline from QemuKernelLoaderFs Dov Murik
2021-06-29 9:44 ` [edk2-devel] " Laszlo Ersek
2021-06-29 10:23 ` Laszlo Ersek
2021-06-28 10:51 ` [PATCH v3 5/5] OvmfPkg/X86QemuLoadImageLib: State fw_cfg dependency in file header Dov Murik
2021-06-29 9:45 ` [edk2-devel] " Laszlo Ersek
2021-06-29 12:54 ` [edk2-devel] [PATCH v3 0/5] OvmfPkg: Use QemuKernelLoaderFs to read cmdline/initrd Laszlo Ersek
2021-06-29 13:03 ` Dov Murik
2021-06-29 13:30 ` Laszlo Ersek
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-list 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=364b6a96-3d06-f478-7e8c-4e46936e6aad@redhat.com \
--to=devel@edk2.groups.io \
/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