summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exec.c
Commit message (Collapse)AuthorAgeFilesLines
* - Borrow the KSE single threading code for exec and exit. We use the checkjeff2003-04-011-1/+1
| | | | | | | | if (p->p_numthreads > 1) and not a flag because action is only necessary if there are other threads. The rest of the system has no need to identify thr threaded processes. - In kern_thread.c use thr_exit1() instead of thread_exit() if P_THREADED is not set.
* Replace the at_fork, at_exec, and at_exit functions with the slightly morejhb2003-03-241-59/+2
| | | | | | | | | flexible process_fork, process_exec, and process_exit eventhandlers. This reduces code duplication and also means that I don't have to go duplicate the eventhandler locking three more times for each of at_fork, at_exec, and at_exit. Reviewed by: phk, jake, almost complete silence on arch@
* - Cache a reference to the credential of the thread that starts a ktrace injhb2003-03-131-3/+8
| | | | | | | | | | | struct proc as p_tracecred alongside the current cache of the vnode in p_tracep. This credential is then used for all later ktrace operations on this file rather than using the credential of the current thread at the time of each ktrace event. - Now that we have multiple ktrace-related items in struct proc that are pointers, rename p_tracep to p_tracevp to make it less ambiguous. Requested by: rwatson (1)
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-2/+2
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-3/+3
| | | | Approved by: trb
* - Split the struct kse into struct upcall and struct kse. struct kse willjeff2003-02-171-3/+0
| | | | | | | soon be visible only to schedulers. This greatly simplifies much the KSE code. Submitted by: davidxu
* Reversion of commit by Davidxu plus fixes since applied.julian2003-02-011-0/+3
| | | | | | | | I'm not convinced there is anything major wrong with the patch but them's the rules.. I am using my "David's mentor" hat to revert this as he's offline for a while.
* Move UPCALL related data structure out of kse, introduce a newdavidxu2003-01-261-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data structure called kse_upcall to manage UPCALL. All KSE binding and loaning code are gone. A thread owns an upcall can collect all completed syscall contexts in its ksegrp, turn itself into UPCALL mode, and takes those contexts back to userland. Any thread without upcall structure has to export their contexts and exit at user boundary. Any thread running in user mode owns an upcall structure, when it enters kernel, if the kse mailbox's current thread pointer is not NULL, then when the thread is blocked in kernel, a new UPCALL thread is created and the upcall structure is transfered to the new UPCALL thread. if the kse mailbox's current thread pointer is NULL, then when a thread is blocked in kernel, no UPCALL thread will be created. Each upcall always has an owner thread. Userland can remove an upcall by calling kse_exit, when all upcalls in ksegrp are removed, the group is atomatically shutdown. An upcall owner thread also exits when process is in exiting state. when an owner thread exits, the upcall it owns is also removed. KSE is a pure scheduler entity. it represents a virtual cpu. when a thread is running, it always has a KSE associated with it. scheduler is free to assign a KSE to thread according thread priority, if thread priority is changed, KSE can be moved from one thread to another. When a ksegrp is created, there is always N KSEs created in the group. the N is the number of physical cpu in the current system. This makes it is possible that even an userland UTS is single CPU safe, threads in kernel still can execute on different cpu in parallel. Userland calls kse_create to add more upcall structures into ksegrp to increase concurrent in userland itself, kernel is not restricted by number of upcalls userland provides. The code hasn't been tested under SMP by author due to lack of hardware. Reviewed by: julian
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-3/+3
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Perform VOP_GETATTR() before mac_check_vnode_exec() so thatrwatson2003-01-211-5/+5
| | | | | | | the cached attributes are available to MAC modules. Submitted by: mike halderman <mrh@nosc.mil> Obtained from: TrustedBSD Project
* It is possible for an active aio to prevent shared memory from beingdillon2003-01-131-2/+1
| | | | | | | | | | | | | dereferenced when a process exits due to the vmspace ref-count being bumped. Change shmexit() and shmexit_myhook() to take a vmspace instead of a process and call it in vmspace_dofree(). This way if it is missed in exit1()'s early-resource-free it will still be caught when the zombie is reaped. Also fix a potential race in shmexit_myhook() by NULLing out vmspace->vm_shm prior to calling shm_delete_mapping() and free(). MFC after: 7 days
* Clear some KSE fields after kse mode was turned off.davidxu2003-01-071-0/+3
|
* Add a sysctl to get the vm protections for the stack of the current process.jake2003-01-041-0/+14
| | | | | | | | On architectures with a non-executable stack, eg sparc64, this is used by libgcc to determine at runtime if its necessary to enable execute permissions on a region of the stack which will be used to execute code, allowing the call to mprotect to be avoided if the kernel is configured to map the stack executable.
* fdcopy() only needs a filedesc pointer.alfred2003-01-011-1/+1
|
* Hold the page queues lock when performing vm_page_busy().alc2002-12-181-0/+2
|
* remove syscallarg().alfred2002-12-141-7/+7
| | | | Suggested by: peter
* To avoid sleeping with all sorts of resources acquired (the reportedrobert2002-11-261-3/+7
| | | | | | | | problem was a locked directory vnode), do not give the process a chance to sleep in state "stopevent" (depends on the S_EXEC bit being set in p_stops) until most resources have been released again. Approved by: re
* Acquire and release the page queues lock around pmap_remove_pages() becausealc2002-11-251-0/+2
| | | | it updates several of vm_page's fields.
* - Release the imgp vnode prior to freeing exec_map resources to avoidjeff2002-11-171-4/+4
| | | | deadlock.
* Now that pmap_remove_all() is exported by our pmap implementationsalc2002-11-161-1/+1
| | | | use it directly.
* When prot is VM_PROT_NONE, call pmap_page_protect() directly rather thanalc2002-11-101-1/+1
| | | | | | | | | indirectly through vm_page_protect(). The one remaining page flag that is updated by vm_page_protect() is already being updated by our various pmap implementations. Note: A later commit will similarly change the VM_PROT_READ case and eliminate vm_page_protect().
* Correct merge-o: disable the right execve() variation if !MACrwatson2002-11-051-4/+4
|
* Bring in two sets of changes:rwatson2002-11-051-8/+72
| | | | | | | | | | | | | | | | | | | | | | (1) Permit userland applications to request a change of label atomic with an execve() via mac_execve(). This is required for the SEBSD port of SELinux/FLASK. Attempts to invoke this without MAC compiled in result in ENOSYS, as with all other MAC system calls. Complexity, if desired, is present in policy modules, rather than the framework. (2) Permit policies to have access to both the label of the vnode being executed as well as the interpreter if it's a shell script or related UNIX nonsense. Because we can't hold both vnode locks at the same time, cache the interpreter label. SEBSD relies on this because it supports secure transitioning via shell script executables. Other policies might want to take both labels into account during an integrity or confidentiality decision at execve()-time. Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Hook up the mac_will_execve_transition() and mac_execve_transition()rwatson2002-11-051-0/+15
| | | | | | | | | | | | | | | | | entrypoints, #ifdef MAC. The supporting logic already existed in kern_mac.c, so no change there. This permits MAC policies to cause a process label change as the result of executing a binary -- typically, as a result of executing a specially labeled binary. For example, the SEBSD port of SELinux/FLASK uses this functionality to implement TE type transitions on processes using transitioning binaries, in a manner similar to setuid. Policies not implementing a notion of transition (all the ones in the tree right now) require no changes, since the old label data is copied to the new label via mac_create_cred() even if a transition does occur. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* Remove reference to struct execve_args from struct imgact, whichrwatson2002-11-051-17/+39
| | | | | | | | | | | | | | | | | describes an image activation instance. Instead, make use of the existing fname structure entry, and introduce two new entries, userspace_argv, and userspace_envv. With the addition of mac_execve(), this divorces the image structure from the specifics of the execve() system call, removes a redundant pointer, etc. No semantic change from current behavior, but it means that the structure doesn't depend on syscalls.master-generated includes. There seems to be some redundant initialization of imgact entries, which I have maintained, but which could probably use some cleaning up at some point. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* - Move the 'done1' label down below the unlock of the proc lock and movejhb2002-10-111-10/+9
| | | | | | | | | | the locking of the proc lock after the goto to done1 to avoid locking the lock in an error case just so we can turn around and unlock it. - Move the exec_setregs() stuff out from under the proc lock and after the p_args stuff. This allows exec_setregs() to be able to sleep or write things out to userland, etc. which ia64 does. Tested by: peter
* Use the fields in the sysentvec and in the vm map header in place of thejake2002-09-211-20/+46
| | | | | | | | constants VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK and PS_STRINGS. This is mainly so that they can be variable even for the native abi, based on different machine types. Get stack protections from the sysentvec too. This makes it trivial to map the stack non-executable for certain abis, on machines that support it.
* Move setugidsafety() call outside of process lock. This prevents a locknjl2002-09-141-3/+5
| | | | | | | recursion when closef() calls pfind() which also wants the proc lock. This case only occurred when setugidsafety() needed to close unsafe files. Reviewed by: truckman
* Drop the proc lock while calling fdcheckstd() which may block to allocatetruckman2002-09-131-1/+8
| | | | | | memory. Reviewed by: jhb
* s/SGNL/SIG/davidxu2002-09-051-1/+1
| | | | | | | | | | s/SNGL/SINGLE/ s/SNGLE/SINGLE/ Fix abbreviation for P_STOPPED_* etc flags, in original code they were inconsistent and difficult to distinguish between them. Approved by: julian (mentor)
* Added fields for VM_MIN_ADDRESS, PS_STRINGS and stack protections tojake2002-09-011-2/+0
| | | | | | sysentvec. Initialized all fields of all sysentvecs, which will allow them to be used instead of constants in more places. Provided stack fixup routines for emulations that previously used the default.
* Renamed poorly named setregs to exec_setregs. Moved its prototype tojake2002-08-291-2/+2
| | | | imgact.h with the other exec support functions.
* Don't require that sysentvec.sv_szsigcode be non-NULL.jake2002-08-291-3/+7
|
* Fixed most indentation bugs.jake2002-08-251-7/+6
|
* Fixed placement of operators. Wrapped long lines.jake2002-08-251-11/+15
|
* Fixed white space around operators, casts and reserved words.jake2002-08-241-9/+8
| | | | Reviewed by: md5
* return x; -> return (x);jake2002-08-241-11/+11
| | | | | | return(x); -> return (x); Reviewed by: md5
* slight cleanup of single-threading code for KSE processesjulian2002-08-221-4/+12
|
* - Hold the vnode lock throughout execve.jeff2002-08-131-11/+36
| | | | | - Set VV_TEXT in the top level execve code. - Fixup the image activators to deal with the newly locked vnode.
* Introduce support for Mandatory Access Control and extensiblerwatson2002-08-011-0/+9
| | | | | | | | | | | | | kernel access control. Invoke an appropriate MAC entry point to authorize execution of a file by a process. The check is placed slightly differently than it appears in the trustedbsd_mac tree so that it prevents a little more information leakage about the target of the execve() operation. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* For processes which are set-user-ID or set-group-ID, the kernel performs a fewnectar2002-07-301-1/+2
| | | | | | | | | | | special actions for safety. One of these is to make sure that file descriptors 0..2 are in use, by opening /dev/null for those that are not already open. Another is to close any file descriptors 0..2 that reference procfs. However, these checks were made out of order, so that it was still possible for a set-user-ID or set-group-ID process to be started with some of the file descriptors 0..2 unused. Submitted by: Georgi Guninski <guninski@guninski.com>
* Slight restructuring of the logic for credential change case identificationrwatson2002-07-271-2/+8
| | | | | | | | | during execve() to use a 'credential_changing' variable. This makes it easier to have outstanding patchsets against this code, as well as to add conditionally defined clauses. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Infrastructure tweaks to allow having both an Elf32 and an Elf64 executablepeter2002-07-201-9/+20
| | | | | | | | | | | | | | | handler in the kernel at the same time. Also, allow for the exec_new_vmspace() code to build a different sized vmspace depending on the executable environment. This is a big help for execing i386 binaries on ia64. The ELF exec code grows the ability to map partial pages when there is a page size difference, eg: emulating 4K pages on 8K or 16K hardware pages. Flesh out the i386 emulation support for ia64. At this point, the only binary that I know of that fails is cvsup, because the cvsup runtime tries to execute code in pages not marked executable. Obtained from: dfr (mostly, many tweaks from me).
* In execve(), delay the acquisition of Giant until after kmem_alloc_wait().alc2002-07-141-2/+2
| | | | (Operations on the exec_map don't require Giant.)
* We don't need to clear oldcred here since newcred is not NULL yet.jhb2002-07-131-3/+1
|
* o Lock accesses to the page queues.alc2002-07-111-1/+6
|
* Clean up execve locking:jeff2002-07-061-0/+8
| | | | | | - Grab the vnode object early in exec when we still have the vnode lock. - Cache the object in the image_params. - Make use of the cached object in imgact_*.c
* #include <sys/ktrace.h> would be useful too. (for ktrace_mtx)peter2002-07-011-0/+3
|
* Add #include "opt_ktrace.h"peter2002-07-011-0/+2
|
* Part 1 of KSE-IIIjulian2002-06-291-4/+6
| | | | | | | | | | | | | The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals..
OpenPOWER on IntegriCloud