2020-04-26 19:51:50

by Heinrich Schuchardt

[permalink] [raw]
Subject: [PATCH 1/1] efi/libstub: setup_graphics() do not return random data

Currently setup_graphics() ignores the return value of efi_setup_gop(). As
AllocatePool() does not zero out memory the screen information table will
contain random data in this case.

We should free the screen information table if efi_setup_gop() returns an
error code.

Signed-off-by: Heinrich Schuchardt <[email protected]>
---
drivers/firmware/efi/libstub/efi-stub.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index ee225b323687..60377e5ceab3 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -55,7 +55,11 @@ static struct screen_info *setup_graphics(void)
si = alloc_screen_info();
if (!si)
return NULL;
- efi_setup_gop(si, &gop_proto, size);
+ status = efi_setup_gop(si, &gop_proto, size);
+ if (status != EFI_SUCCESS) {
+ free_screen_info(si);
+ return NULL;
+ }
}
return si;
}
--
2.26.2


2020-04-27 06:54:44

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH 1/1] efi/libstub: setup_graphics() do not return random data

On Sun, 26 Apr 2020 at 21:49, Heinrich Schuchardt <[email protected]> wrote:
>
> Currently setup_graphics() ignores the return value of efi_setup_gop(). As
> AllocatePool() does not zero out memory the screen information table will
> contain random data in this case.
>
> We should free the screen information table if efi_setup_gop() returns an
> error code.
>
> Signed-off-by: Heinrich Schuchardt <[email protected]>

Thanks Heinrich

I will take this as a fix


> ---
> drivers/firmware/efi/libstub/efi-stub.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
> index ee225b323687..60377e5ceab3 100644
> --- a/drivers/firmware/efi/libstub/efi-stub.c
> +++ b/drivers/firmware/efi/libstub/efi-stub.c
> @@ -55,7 +55,11 @@ static struct screen_info *setup_graphics(void)
> si = alloc_screen_info();
> if (!si)
> return NULL;
> - efi_setup_gop(si, &gop_proto, size);
> + status = efi_setup_gop(si, &gop_proto, size);
> + if (status != EFI_SUCCESS) {
> + free_screen_info(si);
> + return NULL;
> + }
> }
> return si;
> }
> --
> 2.26.2
>

Subject: [tip: efi/urgent] efi/libstub: Avoid returning uninitialized data from setup_graphics()

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID: 081d5150845ba3fa49151a2f55d3cc03b0987509
Gitweb: https://git.kernel.org/tip/081d5150845ba3fa49151a2f55d3cc03b0987509
Author: Heinrich Schuchardt <[email protected]>
AuthorDate: Sun, 26 Apr 2020 21:49:46 +02:00
Committer: Ard Biesheuvel <[email protected]>
CommitterDate: Thu, 30 Apr 2020 23:26:30 +02:00

efi/libstub: Avoid returning uninitialized data from setup_graphics()

Currently, setup_graphics() ignores the return value of efi_setup_gop(). As
AllocatePool() does not zero out memory, the screen information table will
contain uninitialized data in this case.

We should free the screen information table if efi_setup_gop() returns an
error code.

Signed-off-by: Heinrich Schuchardt <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ard Biesheuvel <[email protected]>
---
drivers/firmware/efi/libstub/arm-stub.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 99a5cde..48161b1 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -60,7 +60,11 @@ static struct screen_info *setup_graphics(void)
si = alloc_screen_info();
if (!si)
return NULL;
- efi_setup_gop(si, &gop_proto, size);
+ status = efi_setup_gop(si, &gop_proto, size);
+ if (status != EFI_SUCCESS) {
+ free_screen_info(si);
+ return NULL;
+ }
}
return si;
}