summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exec.c
Commit message (Collapse)AuthorAgeFilesLines
* - 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..
* More caddr_t removal, make fo_ioctl take a void * instead of a caddr_t.alfred2002-06-291-1/+1
|
* o Eliminate vmspace::vm_minsaddr. It's initialized but never used.alc2002-06-251-1/+0
| | | | | o Replace stale comments in vmspace by "const until freed" annotations on some fields.
* Don't leak resources if fdcheckstd() fails during exec.alfred2002-06-201-5/+10
| | | | Submitted by: Mike Makonnen <makonnen@pacbell.net>
* Squish the "could sleep with process lock" messages caused by callingalfred2002-06-191-1/+4
| | | | | | | | | | | | | | | | | | | | uifind() with a proc lock held. change_ruid() and change_euid() have been modified to take a uidinfo structure which will be pre-allocated by callers, they will then call uihold() on the uidinfo structure so that the caller's logic is simplified. This allows one to call uifind() before locking the proc struct and thereby avoid a potential blocking allocation with the proc lock held. This may need revisiting, perhaps keeping a spare uidinfo allocated per process to handle this situation or re-examining if the proc lock needs to be held over the entire operation of changing real or effective user id. Submitted by: Don Lewis <dl-freebsd@catspoiler.org>
* Properly lock accesses to p_tracep and p_traceflag. Also make a fewjhb2002-06-071-1/+10
| | | | ktrace-only things #ifdef KTRACE that were not before.
* - Reorder execve() so that it performs blocking operations before itjhb2002-05-021-61/+73
| | | | | | | | locks the process. - Defer other blocking operations such as vrele()'s until after we release locks. - execsigs() now requires the proc lock to be held when it is called rather than locking the process internally.
* When exec'ing a set[ug]id program, make sure that the stdio file descriptorsnectar2002-04-191-0/+4
| | | | | | | | (0, 1, 2) are allocated by opening /dev/null for any which are not already open. Reviewed by: alfred, phk MFC after: 2 days
* Increase the size of the register stack storage on ia64 from 32K to 2MB sopeter2002-04-051-1/+7
| | | | | | | | | that we can compile gcc. This is a hack because it adds a fixed 2MB to each process's VSIZE regardless of how much is really being used since there is no grow-up stack support. At least it isn't physical memory. Sigh. Add a sysctl to enable tweaking it for new processes.
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-1/+1
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Add a local proc *p in exec_new_vmspace() to avoid repeated dereferencingalc2002-03-311-6/+7
| | | | to obtain it.
* Make the reference counting of 'struct pargs' SMP safe.alfred2002-03-271-6/+2
| | | | | | | | | There is still some locations where the PROC lock should be held in order to prevent inconsistent views from outside (like the proc->p_fd fix for kern/vfs_syscalls.c:checkdirs()) that can be fixed later. Submitted by: Jonathan Mini <mini@haikugeek.com>
* Remove an unnecessary and inconsistently used variable from exec_new_vmspace().alc2002-03-261-3/+1
|
* Remove __P.alfred2002-03-191-2/+2
|
* Convert all pmap_kenter/pmap_kremove pairs in MI code to use pmap_qenter/jake2002-03-171-2/+2
| | | | | | | | | | | | | | | pmap_qremove. pmap_kenter is not safe to use in MI code because it is not guaranteed to flush the mapping from the tlb on all cpus. If the process in question is preempted and migrates cpus between the call to pmap_kenter and pmap_kremove, the original cpu will be left with stale mappings in its tlb. This is currently not a problem for i386 because we do not use PG_G on SMP, and thus all mappings are flushed from the tlb on context switches, not just user mappings. This is not the case on all architectures, and if PG_G is to be used with SMP on i386 it will be a problem. This was committed by peter earlier as part of his fine grained tlb shootdown work for i386, which was backed out for other reasons. Reviewed by: peter
* Remove now unused struct proc *p.imp2002-02-271-1/+0
| | | | Approved by: jhb
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredjhb2002-02-271-9/+7
| | | | reference.
* Back out all the pmap related stuff I've touched over the last few days.peter2002-02-271-2/+2
| | | | | | There is some unresolved badness that has been eluding me, particularly affecting uniprocessor kernels. Turning off PG_G helped (which is a bad sign) but didn't solve it entirely. Userland programs still crashed.
* Jake further reduced IPI shootdowns on sparc64 in loops by using rangedpeter2002-02-271-2/+2
| | | | | | | | shootdowns in a couple of key places. Do the same for i386. This also hides some physical addresses from higher levels and has it use the generic vm_page_t's instead. This will help for PAE down the road. Obtained from: jake (MI code, suggestions for MD part)
* Pre-KSE/M3 commit.julian2002-02-071-1/+1
| | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
* o Call the functions registered with at_exec() from exec_new_vmspace()alc2002-01-131-4/+7
| | | | | | | instead of execve(). Otherwise, the possibility still exists for a pending AIO to modify the new address space. Reviewed by: alfred
* SMP Lock struct file, filedesc and the global file list.alfred2002-01-131-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seigo Tanimura (tanimura) posted the initial delta. I've polished it quite a bit reducing the need for locking and adapting it for KSE. Locks: 1 mutex in each filedesc protects all the fields. protects "struct file" initialization, while a struct file is being changed from &badfileops -> &pipeops or something the filedesc should be locked. 1 mutex in each struct file protects the refcount fields. doesn't protect anything else. the flags used for garbage collection have been moved to f_gcflag which was the FILLER short, this doesn't need locking because the garbage collection is a single threaded container. could likely be made to use a pool mutex. 1 sx lock for the global filelist. struct file * fhold(struct file *fp); /* increments reference count on a file */ struct file * fhold_locked(struct file *fp); /* like fhold but expects file to locked */ struct file * ffind_hold(struct thread *, int fd); /* finds the struct file in thread, adds one reference and returns it unlocked */ struct file * ffind_lock(struct thread *, int fd); /* ffind_hold, but returns file locked */ I still have to smp-safe the fget cruft, I'll get to that asap.
* Make AIO a loadable module.alfred2001-12-291-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | Remove the explicit call to aio_proc_rundown() from exit1(), instead AIO will use at_exit(9). Add functions at_exec(9), rm_at_exec(9) which function nearly the same as at_exec(9) and rm_at_exec(9), these functions are called on behalf of modules at the time of execve(2) after the image activator has run. Use a modified version of tegge's suggestion via at_exec(9) to close an exploitable race in AIO. Fix SYSCALL_MODULE_HELPER such that it's archetecuterally neutral, the problem was that one had to pass it a paramater indicating the number of arguments which were actually the number of "int". Fix it by using an inline version of the AS macro against the syscall arguments. (AS should be available globally but we'll get to that later.) Add a primative system for dynamically adding kqueue ops, it's really not as sophisticated as it should be, but I'll discuss with jlemon when he's around.
* Repeat after me -- "Use of ANSI string concatenation can be bad."obrien2001-12-101-1/+1
| | | | | | | | In this case, C99's __func__ is properly defined as: static const char __func__[] = "function-name"; and GCC 3.1 will not allow it to be used in bogus string concatenation.
* For what its worth, sync up the type of ps_arg_cache_max (unsigned long)peter2001-11-081-1/+1
| | | | with the sysctl type (signed long).
* Add a P_INEXEC flag that indicates that the process has called execve() anddes2001-10-271-15/+25
| | | | | | | | it has not yet returned. Use this flag to deny debugging requests while the process is execve()ing, and close once and for all any race conditions that might occur between execve() and various debugging interfaces. Reviewed by: jhb, rwatson
OpenPOWER on IntegriCloud