CVSROOT: /cvs Module name: src Changes by: bl...@cvs.openbsd.org 2024/06/05 18:36:46
Modified files: sys/arch/amd64/amd64: copy.S sys/arch/i386/i386: locore.s Log message: Clear DF flag after kcopy faulted. A memory corruption in the kernel happend that was caused by memset in the wrong direction. After that DF bit was set in ddb rflags. Only kcopy and memmove use std to set DF bit. kcopy has the special property that it can fault. In this case DF is set in the trap frame. kpageflttrap() changes the return address to copy_fault via pcb_onfault. When alltraps_kern returns, it restores the rflags with DF set and jumps into copy_fault. From there a function return goes back into regular kernel execution. Now DF is set, but kernel memset and memcpy expect that it is cleared. After copy fault, also reset the DF bit with cld in copy_fault. The crash happend on OpenBSD 7.4 amd64. As i386 code looks similar, also insert cld there. OK guenther@ miod@