The code was reading pg->pg_flags, so clang assumed pg != NULL, then
optimized a later "if (pg != NULL)" to "if (1)", and allowed a call to
pmap_enter_pv(pted, NULL). Such a call can freeze bsd.mp by trying to
lock NULL's ((struct mutex *)0x3c). I froze bsd.mp this way by
starting Xorg on a macppc with nv(4) or r128(4) video, as it tried to
mmap the xf86(4) aperture.
ok miod@
-/* $OpenBSD: pmap.c,v 1.180 2023/01/31 15:18:55 deraadt Exp $ */
+/* $OpenBSD: pmap.c,v 1.181 2023/02/06 06:41:38 gkoehler Exp $ */
/*
* Copyright (c) 2015 Martin Pieuchot
}
pg = PHYS_TO_VM_PAGE(pa);
- if (pg->pg_flags & PG_PMAP_UC)
+ if (pg != NULL && (pg->pg_flags & PG_PMAP_UC))
nocache = TRUE;
if (wt)
cache = PMAP_CACHE_WT;