* [PATCH 5.3 regression fix] efi-stub: Fix get_efi_config_table on mixed-mode setups
@ 2019-08-07 21:59 Hans de Goede
2019-08-07 23:03 ` Matthew Garrett
2019-08-08 15:11 ` Jarkko Sakkinen
0 siblings, 2 replies; 4+ messages in thread
From: Hans de Goede @ 2019-08-07 21:59 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Hans de Goede, Peter Huewe, x86, linux-efi, linux-integrity,
Matthew Garrett, Jarkko Sakkinen
Fix get_efi_config_table using the wrong structs when booting a
64 bit kernel on 32 bit firmware.
Cc: Matthew Garrett <mjg59@google.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Fixes: 82d736ac56d7 ("Abstract out support for locating an EFI config table")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
.../firmware/efi/libstub/efi-stub-helper.c | 38 +++++++++++++------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 1db780c0f07b..3caae7f2cf56 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -927,17 +927,33 @@ efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg,
return status;
}
+#define GET_EFI_CONFIG_TABLE(bits) \
+static void *get_efi_config_table##bits(efi_system_table_t *_sys_table, \
+ efi_guid_t guid) \
+{ \
+ efi_system_table_##bits##_t *sys_table; \
+ efi_config_table_##bits##_t *tables; \
+ int i; \
+ \
+ sys_table = (typeof(sys_table))_sys_table; \
+ tables = (typeof(tables))(unsigned long)sys_table->tables; \
+ \
+ for (i = 0; i < sys_table->nr_tables; i++) { \
+ if (efi_guidcmp(tables[i].guid, guid) != 0) \
+ continue; \
+ \
+ return (void *)(unsigned long)tables[i].table; \
+ } \
+ \
+ return NULL; \
+}
+GET_EFI_CONFIG_TABLE(32)
+GET_EFI_CONFIG_TABLE(64)
+
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid)
{
- efi_config_table_t *tables = (efi_config_table_t *)sys_table->tables;
- int i;
-
- for (i = 0; i < sys_table->nr_tables; i++) {
- if (efi_guidcmp(tables[i].guid, guid) != 0)
- continue;
-
- return (void *)tables[i].table;
- }
-
- return NULL;
+ if (efi_is_64bit())
+ return get_efi_config_table64(sys_table, guid);
+ else
+ return get_efi_config_table32(sys_table, guid);
}
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 5.3 regression fix] efi-stub: Fix get_efi_config_table on mixed-mode setups
2019-08-07 21:59 [PATCH 5.3 regression fix] efi-stub: Fix get_efi_config_table on mixed-mode setups Hans de Goede
@ 2019-08-07 23:03 ` Matthew Garrett
2019-08-08 7:34 ` Ard Biesheuvel
2019-08-08 15:11 ` Jarkko Sakkinen
1 sibling, 1 reply; 4+ messages in thread
From: Matthew Garrett @ 2019-08-07 23:03 UTC (permalink / raw)
To: Hans de Goede
Cc: Ard Biesheuvel, Peter Huewe, x86, linux-efi, linux-integrity,
Jarkko Sakkinen
On Wed, Aug 7, 2019 at 2:59 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Fix get_efi_config_table using the wrong structs when booting a
> 64 bit kernel on 32 bit firmware.
>
> Cc: Matthew Garrett <mjg59@google.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Fixes: 82d736ac56d7 ("Abstract out support for locating an EFI config table")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-By: Matthew Garrett <mjg59@google.com>
Good catch. I think fixing this is preferable to reverting - the
duplicate events are visible to userland, so there's a risk that apps
will end up depending on them if there's a release that behaves that
way. Presumably mixed mode isn't a thing on ARM?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5.3 regression fix] efi-stub: Fix get_efi_config_table on mixed-mode setups
2019-08-07 23:03 ` Matthew Garrett
@ 2019-08-08 7:34 ` Ard Biesheuvel
0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2019-08-08 7:34 UTC (permalink / raw)
To: Matthew Garrett
Cc: Hans de Goede, Peter Huewe, the arch/x86 maintainers, linux-efi,
linux-integrity, Jarkko Sakkinen
On Thu, 8 Aug 2019 at 02:03, Matthew Garrett <mjg59@google.com> wrote:
>
> On Wed, Aug 7, 2019 at 2:59 PM Hans de Goede <hdegoede@redhat.com> wrote:
> >
> > Fix get_efi_config_table using the wrong structs when booting a
> > 64 bit kernel on 32 bit firmware.
> >
> > Cc: Matthew Garrett <mjg59@google.com>
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > Fixes: 82d736ac56d7 ("Abstract out support for locating an EFI config table")
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>
> Acked-By: Matthew Garrett <mjg59@google.com>
>
Thanks for fixing this, Hans.
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Good catch. I think fixing this is preferable to reverting - the
> duplicate events are visible to userland, so there's a risk that apps
> will end up depending on them if there's a release that behaves that
> way.
Agreed, I will send this out as a fix.
> Presumably mixed mode isn't a thing on ARM?
Nope. I should have realised this when we made this routine generic,
but I failed to spot it. ARM is either strictly 32-bit or strictly
64-bit.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5.3 regression fix] efi-stub: Fix get_efi_config_table on mixed-mode setups
2019-08-07 21:59 [PATCH 5.3 regression fix] efi-stub: Fix get_efi_config_table on mixed-mode setups Hans de Goede
2019-08-07 23:03 ` Matthew Garrett
@ 2019-08-08 15:11 ` Jarkko Sakkinen
1 sibling, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2019-08-08 15:11 UTC (permalink / raw)
To: Hans de Goede
Cc: Ard Biesheuvel, Peter Huewe, x86, linux-efi, linux-integrity,
Matthew Garrett
On Wed, Aug 07, 2019 at 11:59:03PM +0200, Hans de Goede wrote:
> Fix get_efi_config_table using the wrong structs when booting a
> 64 bit kernel on 32 bit firmware.
>
> Cc: Matthew Garrett <mjg59@google.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Fixes: 82d736ac56d7 ("Abstract out support for locating an EFI config table")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
/Jarkko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-08 15:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 21:59 [PATCH 5.3 regression fix] efi-stub: Fix get_efi_config_table on mixed-mode setups Hans de Goede
2019-08-07 23:03 ` Matthew Garrett
2019-08-08 7:34 ` Ard Biesheuvel
2019-08-08 15:11 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).