提交 0b3225ab 编写于 作者: A Ard Biesheuvel 提交者: Ingo Molnar

efi: Avoid potential crashes, fix the 'struct efi_pci_io_protocol_32' definition for mixed mode

Mixed mode allows a kernel built for x86_64 to interact with 32-bit
EFI firmware, but requires us to define all struct definitions carefully
when it comes to pointer sizes.

'struct efi_pci_io_protocol_32' currently uses a 'void *' for the
'romimage' field, which will be interpreted as a 64-bit field
on such kernels, potentially resulting in bogus memory references
and subsequent crashes.
Tested-by: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
Cc: <stable@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20180504060003.19618-13-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 67b8d5c7
...@@ -163,7 +163,8 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom) ...@@ -163,7 +163,8 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom)
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_struct; goto free_struct;
memcpy(rom->romdata, pci->romimage, pci->romsize); memcpy(rom->romdata, (void *)(unsigned long)pci->romimage,
pci->romsize);
return status; return status;
free_struct: free_struct:
...@@ -269,7 +270,8 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom) ...@@ -269,7 +270,8 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom)
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_struct; goto free_struct;
memcpy(rom->romdata, pci->romimage, pci->romsize); memcpy(rom->romdata, (void *)(unsigned long)pci->romimage,
pci->romsize);
return status; return status;
free_struct: free_struct:
......
...@@ -395,8 +395,8 @@ typedef struct { ...@@ -395,8 +395,8 @@ typedef struct {
u32 attributes; u32 attributes;
u32 get_bar_attributes; u32 get_bar_attributes;
u32 set_bar_attributes; u32 set_bar_attributes;
uint64_t romsize; u64 romsize;
void *romimage; u32 romimage;
} efi_pci_io_protocol_32; } efi_pci_io_protocol_32;
typedef struct { typedef struct {
...@@ -415,8 +415,8 @@ typedef struct { ...@@ -415,8 +415,8 @@ typedef struct {
u64 attributes; u64 attributes;
u64 get_bar_attributes; u64 get_bar_attributes;
u64 set_bar_attributes; u64 set_bar_attributes;
uint64_t romsize; u64 romsize;
void *romimage; u64 romimage;
} efi_pci_io_protocol_64; } efi_pci_io_protocol_64;
typedef struct { typedef struct {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册