Date: Thu, 22 Mar 2018 15:32:57 +0000 (UTC) From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331361 - head/sys/dev/efidev Message-ID: <201803221532.w2MFWv8W047088@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andrew Date: Thu Mar 22 15:32:57 2018 New Revision: 331361 URL: https://svnweb.freebsd.org/changeset/base/331361 Log: Enter into the EFI environment before dereferencing the runtime services pointer. This may be within the EFI address space and not the FreeBSD kernel address space. X-MFC-With: r330868 Sponsored by: DARPA, AFRL Modified: head/sys/dev/efidev/efirt.c Modified: head/sys/dev/efidev/efirt.c ============================================================================== --- head/sys/dev/efidev/efirt.c Thu Mar 22 15:24:26 2018 (r331360) +++ head/sys/dev/efidev/efirt.c Thu Mar 22 15:32:57 2018 (r331361) @@ -88,6 +88,9 @@ static int efi_status2err[25] = { EPROTO /* EFI_PROTOCOL_ERROR */ }; +static int efi_enter(void); +static void efi_leave(void); + static int efi_status_to_errno(efi_status status) { @@ -190,9 +193,14 @@ efi_init(void) * call RS->SetVirtualAddressMap. As this is not always the case, e.g. * with an old loader.efi, check if the RS->GetTime function is within * the EFI map, and fail to attach if not. + * + * We need to enter into the EFI environment as efi_runtime may point + * to an EFI address. */ + efi_enter(); if (!efi_is_in_map(map, efihdr->memory_size / efihdr->descriptor_size, efihdr->descriptor_size, (vm_offset_t)efi_runtime->rt_gettime)) { + efi_leave(); if (bootverbose) printf( "EFI runtime services table has an invalid pointer\n"); @@ -200,6 +208,7 @@ efi_init(void) efi_destroy_1t1_map(); return (ENXIO); } + efi_leave(); return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803221532.w2MFWv8W047088>