Prevent loading SGX with incorrect EPC data
It may happen on some machines, that even if SGX is disabled in firmware, the driver would still attach despite EPC base and size equal zero. Such behaviour causes a kernel panic when the module is unloaded. Add a simple check to make sure we only attach when these values are correctly set. Submitted by: Kornel Duleba <mindal@semihalf.com> Reviewed by: br Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D19595
This commit is contained in:
parent
c788d9b010
commit
3caad0b8f4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345288
@ -1075,6 +1075,12 @@ sgx_get_epc_area(struct sgx_softc *sc)
|
||||
(cp[2] & 0xfffff000);
|
||||
sc->npages = sc->epc_size / SGX_PAGE_SIZE;
|
||||
|
||||
if (sc->epc_size == 0 || sc->epc_base == 0) {
|
||||
printf("%s: Incorrect EPC data: EPC base %lx, size %lu\n",
|
||||
__func__, sc->epc_base, sc->epc_size);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
if (cp[3] & 0xffff)
|
||||
sc->enclave_size_max = (1 << ((cp[3] >> 8) & 0xff));
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user