git: 0861c7d3e048 - main - kern: efirt: enter runtime environment to deref efi_cfgtbl

Kyle Evans kevans at FreeBSD.org
Tue Dec 29 17:39:06 UTC 2020


The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=0861c7d3e048556841fa5085173660dceadc5646

commit 0861c7d3e048556841fa5085173660dceadc5646
Author:     Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2020-12-27 17:28:32 +0000
Commit:     Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2020-12-29 17:38:14 +0000

    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
---
 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 df1f62f39126..269eb67cf01f 100644
--- a/sys/dev/efidev/efirt.c
+++ b/sys/dev/efidev/efirt.c
@@ -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);
 }
 


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