Fix sendmail improper close-on-exec flag handling. [SA-14:11] Fix ktrace memory disclosure. [SA-14:12] Fix incorrect error handling in PAM policy parser. [SA-14:13] Fix triple-fault when executing from a threaded process. [EN-14:06]
86 lines
2.8 KiB
Diff
86 lines
2.8 KiB
Diff
Index: sys/kern/kern_exec.c
|
|
===================================================================
|
|
--- sys/kern/kern_exec.c (revision 266584)
|
|
+++ sys/kern/kern_exec.c (revision 266585)
|
|
@@ -282,6 +282,7 @@ kern_execve(td, args, mac_p)
|
|
struct mac *mac_p;
|
|
{
|
|
struct proc *p = td->td_proc;
|
|
+ struct vmspace *oldvmspace;
|
|
int error;
|
|
|
|
AUDIT_ARG_ARGV(args->begin_argv, args->argc,
|
|
@@ -298,6 +299,8 @@ kern_execve(td, args, mac_p)
|
|
PROC_UNLOCK(p);
|
|
}
|
|
|
|
+ KASSERT((td->td_pflags & TDP_EXECVMSPC) == 0, ("nested execve"));
|
|
+ oldvmspace = td->td_proc->p_vmspace;
|
|
error = do_execve(td, args, mac_p);
|
|
|
|
if (p->p_flag & P_HADTHREADS) {
|
|
@@ -312,6 +315,12 @@ kern_execve(td, args, mac_p)
|
|
thread_single_end();
|
|
PROC_UNLOCK(p);
|
|
}
|
|
+ if ((td->td_pflags & TDP_EXECVMSPC) != 0) {
|
|
+ KASSERT(td->td_proc->p_vmspace != oldvmspace,
|
|
+ ("oldvmspace still used"));
|
|
+ vmspace_free(oldvmspace);
|
|
+ td->td_pflags &= ~TDP_EXECVMSPC;
|
|
+ }
|
|
|
|
return (error);
|
|
}
|
|
Index: sys/sys/proc.h
|
|
===================================================================
|
|
--- sys/sys/proc.h (revision 266584)
|
|
+++ sys/sys/proc.h (revision 266585)
|
|
@@ -426,6 +426,7 @@ do { \
|
|
#define TDP_NERRNO 0x08000000 /* Last errno is already in td_errno */
|
|
#define TDP_UIOHELD 0x10000000 /* Current uio has pages held in td_ma */
|
|
#define TDP_DEVMEMIO 0x20000000 /* Accessing memory for /dev/mem */
|
|
+#define TDP_EXECVMSPC 0x40000000 /* Execve destroyed old vmspace */
|
|
|
|
/*
|
|
* Reasons that the current thread can not be run yet.
|
|
Index: sys/sys
|
|
===================================================================
|
|
--- sys/sys (revision 266584)
|
|
+++ sys/sys (revision 266585)
|
|
|
|
Property changes on: sys/sys
|
|
___________________________________________________________________
|
|
Modified: svn:mergeinfo
|
|
Merged /head/sys/sys:r266464
|
|
Index: sys/vm/vm_map.c
|
|
===================================================================
|
|
--- sys/vm/vm_map.c (revision 266584)
|
|
+++ sys/vm/vm_map.c (revision 266585)
|
|
@@ -3752,6 +3752,8 @@ vmspace_exec(struct proc *p, vm_offset_t minuser,
|
|
struct vmspace *oldvmspace = p->p_vmspace;
|
|
struct vmspace *newvmspace;
|
|
|
|
+ KASSERT((curthread->td_pflags & TDP_EXECVMSPC) == 0,
|
|
+ ("vmspace_exec recursed"));
|
|
newvmspace = vmspace_alloc(minuser, maxuser);
|
|
if (newvmspace == NULL)
|
|
return (ENOMEM);
|
|
@@ -3768,7 +3770,7 @@ vmspace_exec(struct proc *p, vm_offset_t minuser,
|
|
PROC_VMSPACE_UNLOCK(p);
|
|
if (p == curthread->td_proc)
|
|
pmap_activate(curthread);
|
|
- vmspace_free(oldvmspace);
|
|
+ curthread->td_pflags |= TDP_EXECVMSPC;
|
|
return (0);
|
|
}
|
|
|
|
Index: sys
|
|
===================================================================
|
|
--- sys (revision 266584)
|
|
+++ sys (revision 266585)
|
|
|
|
Property changes on: sys
|
|
___________________________________________________________________
|
|
Modified: svn:mergeinfo
|
|
Merged /head/sys:r266464
|