kern: efirt: enter runtime environment to deref efi_cfgtbl

This fixes an insta-panic when EFIIOC_GET_TABLE is used.

Reviewed by:	imp (earlier version), kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27669
This commit is contained in:
Kyle Evans 2020-12-27 11:28:32 -06:00
parent ec52ff6d14
commit 0861c7d3e0

View File

@ -314,18 +314,25 @@ efi_get_table(struct uuid *uuid, void **ptr)
{
struct efi_cfgtbl *ct;
u_long count;
int error;
if (efi_cfgtbl == NULL || efi_systbl == NULL)
return (ENXIO);
error = efi_enter();
if (error != 0)
return (error);
count = efi_systbl->st_entries;
ct = efi_cfgtbl;
while (count--) {
if (!bcmp(&ct->ct_uuid, uuid, sizeof(*uuid))) {
*ptr = (void *)efi_phys_to_kva(ct->ct_data);
efi_leave();
return (0);
}
ct++;
}
efi_leave();
return (ENOENT);
}