diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2023-04-08 20:30:47 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2023-04-08 20:30:47 +0000 |
commit | 60b1a2f82dc96b254d6dec1bfd1c14ca056c21dd (patch) | |
tree | 1de5c2c26d7f7d0a0def0bbe4c11971a12735730 /sys/src/9/imx8/main.c | |
parent | bd43bd6f1ae1b1ec7ee6873d9fd6766b049802e9 (diff) |
kernel: Clear secrets on reboot
The idea is that when we reboot, we zero out
memory written by processes that have the private
flag set (such as factotum and keyfs), and also
clear the secrmem pool, which contains TLS keys
and the state of the random number generator.
This is so the newly booted kernel or firmware
will not find these secret keys in memory.
Diffstat (limited to 'sys/src/9/imx8/main.c')
-rw-r--r-- | sys/src/9/imx8/main.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/src/9/imx8/main.c b/sys/src/9/imx8/main.c index 8c90c63ac..dc64115bf 100644 --- a/sys/src/9/imx8/main.c +++ b/sys/src/9/imx8/main.c @@ -357,8 +357,13 @@ exit(int) cpushutdown(); splfhi(); - if(m->machno == 0) + if(m->machno == 0){ + /* clear secrets */ + zeroprivatepages(); + poolreset(secrmem); + u.r0 = 0x84000009; /* SYSTEM RESET */ + } smccall(&u); } @@ -408,6 +413,10 @@ reboot(void*, void *code, ulong size) clockshutdown(); intrsoff(); + /* clear secrets */ + zeroprivatepages(); + poolreset(secrmem); + /* off we go - never to return */ rebootjump((void*)(KTZERO-KZERO), code, size); } |