Date: Sun, 13 Oct 2019 06:56:45 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353463 - head/sys/vm Message-ID: <201910130656.x9D6ujnS044334@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sun Oct 13 06:56:45 2019 New Revision: 353463 URL: https://svnweb.freebsd.org/changeset/base/353463 Log: Restore nofaulting operations after r352807 The TDP_NOFAULTING flag should be checked in vm_fault(), not in vm_fault_trap(). Otherwise kernel accesses to userspace, like vn_io_fault(), enter vm locking when it should not. Reported and tested by: pho Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D21992 Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Oct 13 05:11:53 2019 (r353462) +++ head/sys/vm/vm_fault.c Sun Oct 13 06:56:45 2019 (r353463) @@ -554,15 +554,11 @@ int vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, int fault_flags, int *signo, int *ucode) { - struct thread *td; int result; MPASS(signo == NULL || ucode != NULL); - td = curthread; - if ((td->td_pflags & TDP_NOFAULTING) != 0) - return (KERN_PROTECTION_FAILURE); #ifdef KTRACE - if (map != kernel_map && KTRPOINT(td, KTR_FAULT)) + if (map != kernel_map && KTRPOINT(curthread, KTR_FAULT)) ktrfault(vaddr, fault_type); #endif result = vm_fault(map, trunc_page(vaddr), fault_type, fault_flags, @@ -574,7 +570,7 @@ vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot result == KERN_OUT_OF_BOUNDS, ("Unexpected Mach error %d from vm_fault()", result)); #ifdef KTRACE - if (map != kernel_map && KTRPOINT(td, KTR_FAULTEND)) + if (map != kernel_map && KTRPOINT(curthread, KTR_FAULTEND)) ktrfaultend(result); #endif if (result != KERN_SUCCESS && signo != NULL) { @@ -644,6 +640,10 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fa bool dead, hardfault, is_first_object_locked; VM_CNT_INC(v_vm_faults); + + if ((curthread->td_pflags & TDP_NOFAULTING) != 0) + return (KERN_PROTECTION_FAILURE); + fs.vp = NULL; faultcount = 0; nera = -1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910130656.x9D6ujnS044334>