git: 63882ce21586 - stable/12 - kern: efirt: enter runtime environment to deref efi_cfgtbl

Kyle Evans kevans at FreeBSD.org
Sun Jan 10 05:59:01 UTC 2021


The branch stable/12 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=63882ce21586f6904ae4faf9dbbf73b560378773

commit 63882ce21586f6904ae4faf9dbbf73b560378773
Author:     Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2020-12-27 17:28:32 +0000
Commit:     Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2021-01-10 05:58:43 +0000

    kern: efirt: enter runtime environment to deref efi_cfgtbl
    
    This fixes an insta-panic when EFIIOC_GET_TABLE is used.
    
    (cherry picked from commit 0861c7d3e048556841fa5085173660dceadc5646)
---
 sys/dev/efidev/efirt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys/dev/efidev/efirt.c b/sys/dev/efidev/efirt.c
index ccbae5701e18..9eaaba9801fd 100644
--- a/sys/dev/efidev/efirt.c
+++ b/sys/dev/efidev/efirt.c
@@ -285,18 +285,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);
 }
 


More information about the dev-commits-src-all mailing list