diff options
author | Mark Johnston <markj@FreeBSD.org> | 2024-02-08 16:02:48 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2024-02-08 16:35:11 +0000 |
commit | 01bb9a2a3557bc9389f628d301cd691e08266f1d (patch) | |
tree | 41ea573ea473b0403fc81df2b80e82d70d151a73 | |
parent | 5fa4151e925c39c4d788918badec2ec7b4cc8938 (diff) | |
download | src-01bb9a2a3557bc9389f628d301cd691e08266f1d.tar.gz src-01bb9a2a3557bc9389f628d301cd691e08266f1d.zip |
arm64: Disable kernel superpage promotion when KMSAN is configured
The break-before-make operation required to promote or demote a
superpage leaves a window where the KMSAN runtime can trigger a fatal
data abort. More specifically, the code in pmap_update_entry() which
executes after ATTR_DESCR_VALID is cleared may implicitly attempt to
access KMSAN context via curthread, but we may be promoting or demoting
a 2MB page containing the curthread structure.
Reviewed by: imp
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43158
-rw-r--r-- | sys/arm64/arm64/pmap.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 7c7a9a08fd30..6a84b6bb80f8 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -728,6 +728,18 @@ pmap_ps_enabled(pmap_t pmap) if (pmap->pm_stage != PM_STAGE1) return (false); +#ifdef KMSAN + /* + * The break-before-make in pmap_update_entry() results in a situation + * where a CPU may call into the KMSAN runtime while the entry is + * invalid. If the entry is used to map the current thread structure, + * then the runtime will attempt to access unmapped memory. Avoid this + * by simply disabling superpage promotion for the kernel map. + */ + if (pmap == kernel_pmap) + return (false); +#endif + return (superpages_enabled != 0); } |