From 3730695151008c2f83ee606d87f6561a597fd463 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 2 Jul 2019 19:01:14 +0000 Subject: [PATCH] Use traditional 'p' local to designate td->td_proc in kern_mmap. Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D20795 --- sys/vm/vm_mmap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 24864889060c..be06a5cb5699 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -187,6 +187,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags, { struct vmspace *vms; struct file *fp; + struct proc *p; vm_offset_t addr; vm_size_t pageoff, size; vm_prot_t cap_maxprot; @@ -199,6 +200,9 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags, prot = PROT_EXTRACT(prot); if (max_prot != 0 && (max_prot & prot) != prot) return (EINVAL); + + p = td->td_proc; + /* * Always honor PROT_MAX if set. If not, default to all * permissions unless we're implying maximum permissions. @@ -209,7 +213,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags, max_prot = (imply_prot_max && prot != PROT_NONE) ? prot : _PROT_ALL; - vms = td->td_proc->p_vmspace; + vms = p->p_vmspace; fp = NULL; AUDIT_ARG_FD(fd); addr = addr0; @@ -229,7 +233,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags, * pos. */ if (!SV_CURPROC_FLAG(SV_AOUT)) { - if ((len == 0 && curproc->p_osrel >= P_OSREL_MAP_ANON) || + if ((len == 0 && p->p_osrel >= P_OSREL_MAP_ANON) || ((flags & MAP_ANON) != 0 && (fd != -1 || pos != 0))) return (EINVAL); } else { @@ -375,7 +379,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags, if (error != 0) goto done; if ((flags & (MAP_SHARED | MAP_PRIVATE)) == 0 && - td->td_proc->p_osrel >= P_OSREL_MAP_FSTRICT) { + p->p_osrel >= P_OSREL_MAP_FSTRICT) { error = EINVAL; goto done; }