summaryrefslogtreecommitdiff
path: root/sys/kern/imgact_elf.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix multiple registration of the elf_legacy_coredump sysctl variable.Marcel Moolenaar2002-12-211-3/+5
| | | | | | | | | | | | | | | | | | | | | | | The duplication is caused by the fact that imgact_elf.c is included by both imgact_elf32.c and imgact_elf64.c and both are compiled by default on ia64. Consequently, we have two seperate copies of the elf_legacy_coredump variable due to them being declared static, and two entries for the same sysctl in the linker set, both referencing the unique copy of the elf_legacy_coredump variable. Since the second sysctl cannot be registered, one of the elf_legacy_coredump variables can not be tuned (if ordering still holds, it's the ELF64 related one). The only solution is to create two different sysctl variables, just like the elf<32|64>_trace sysctl variables. This unfortunately is an (user) interface change, but unavoidable. Thus, on ELF32 platforms the sysctl variable is called elf32_legacy_coredump and on ELF64 platforms it is called elf64_legacy_coredump. Platforms that have both ELF formats have both sysctl variables. These variables should probably be retired sooner rather than later. Notes: svn path=/head/; revision=108148
* Change the way ELF coredumps are handled. Instead of unconditionallyMatthew Dillon2002-12-161-11/+31
| | | | | | | | | | | | | | | | | | | | | | skipping read-only pages, which can result in valuable non-text-related data not getting dumped, the ELF loader and the dynamic loader now mark read-only text pages NOCORE and the coredump code only checks (primarily) for complete inaccessibility of the page or NOCORE being set. Certain applications which map large amounts of read-only data will produce much larger cores. A new sysctl has been added, debug.elf_legacy_coredump, which will revert to the old behavior. This commit represents collaborative work by all parties involved. The PR contains a program demonstrating the problem. PR: kern/45994 Submitted by: "Peter Edwards" <pmedwards@eircom.net>, Archie Cobbs <archie@dellroad.org> Reviewed by: jdp, dillon MFC after: 7 days Notes: svn path=/head/; revision=107948
* Assign value of NULL to imgp->execlabel when imgp is initializedRobert Watson2002-11-081-0/+1
| | | | | | | | | | | in the ELF code. Missed in earlier merge from the MAC tree. Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=106660
* Remove reference to struct execve_args from struct imgact, whichRobert Watson2002-11-051-1/+2
| | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=106437
* Handle binaries with arbitrary number PT_LOAD sections, not onlyAlexander Kabaev2002-10-231-14/+19
| | | | | | | | | | | | ones with one text and one data section. The text and data rlimit checks still needs to be fixed to properly accout for additional sections. Reviewed by: peter (slightly different patch version) Notes: svn path=/head/; revision=105755
* Use strlcpy() instead of strncpy() to copy NUL terminated stringsRobert Drehmel2002-10-171-2/+2
| | | | | | | for safety and consistency. Notes: svn path=/head/; revision=105354
* Use the fields in the sysentvec and in the vm map header in place of theJake Burkholder2002-09-211-2/+1
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=103767
* Do not blow up when we walk off the end of the brands list.Peter Wemm2002-09-081-1/+3
| | | | | | | Found by: kris, jake Notes: svn path=/head/; revision=103087
* Alright, fix the problems with the elf loader for the Alpha. It turnsMatthew Dillon2002-09-041-8/+18
| | | | | | | | | | | | | | | | | | | out that there is no easy way to discern the difference between a text segment and a data segment through the read-only OR execute attribute in the elf segment header, so revert the algorithm to what it was before. Neither can we account for multiple data load segments in the vmspace structure (at least not without more work), due to assumptions obreak() makes in regards to the data start and data size fields. Retain RLIMIT_VMEM checking by using a local variable to track the total bytes of data being loaded. Reviewed by: peter X-MFC after: ASAP Notes: svn path=/head/; revision=102922
* Make the text segment locating heuristics from rev 1.121 more reliablePeter Wemm2002-09-031-15/+10
| | | | | | | | | | | so that it works on the Alpha. This defines the segment that the entry point exists in as 'text' and any others (usually one) as data. Submitted by: tmm Tested on: i386, alpha Notes: svn path=/head/; revision=102913
* Grammer cleanupMatthew Dillon2002-09-021-2/+2
| | | | Notes: svn path=/head/; revision=102857
* Moved elf brand identification into a function. Fully identify theJake Burkholder2002-09-021-105/+75
| | | | | | | | | | | brand early in the process of loading an elf file, so that we can identify the sysentvec, and so that we do not continue if we do not have a brand (and thus a sysentvec). Use the values in the sysentvec for the page size and vm ranges unconditionally, since they are all filled in now. Notes: svn path=/head/; revision=102836
* Fixed more indentation bugs.Jake Burkholder2002-09-021-3/+3
| | | | Notes: svn path=/head/; revision=102832
* Implement data, text, and vmem limit checking in the elf loader and svr4Matthew Dillon2002-08-301-10/+33
| | | | | | | | | | compat code. Clean up accounting for multiple segments. Part 1/2. Submitted by: Andrey Alekseyev <uitm@zenon.net> (with some modifications) MFC after: 3 days Notes: svn path=/head/; revision=102630
* Fixed most indentation bugs.Jake Burkholder2002-08-251-46/+34
| | | | Notes: svn path=/head/; revision=102424
* Fixed placement of operators. Wrapped long lines.Jake Burkholder2002-08-251-4/+8
| | | | Notes: svn path=/head/; revision=102423
* Fixed white space around operators, casts and reserved words.Jake Burkholder2002-08-241-23/+22
| | | | | | | Reviewed by: md5 Notes: svn path=/head/; revision=102381
* return x; -> return (x);Jake Burkholder2002-08-241-32/+32
| | | | | | | | | return(x); -> return (x); Reviewed by: md5 Notes: svn path=/head/; revision=102377
* In order to better support flexible and extensible access control,Robert Watson2002-08-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | make a series of modifications to the credential arguments relating to file read and write operations to cliarfy which credential is used for what: - Change fo_read() and fo_write() to accept "active_cred" instead of "cred", and change the semantics of consumers of fo_read() and fo_write() to pass the active credential of the thread requesting an operation rather than the cached file cred. The cached file cred is still available in fo_read() and fo_write() consumers via fp->f_cred. These changes largely in sys_generic.c. For each implementation of fo_read() and fo_write(), update cred usage to reflect this change and maintain current semantics: - badfo_readwrite() unchanged - kqueue_read/write() unchanged pipe_read/write() now authorize MAC using active_cred rather than td->td_ucred - soo_read/write() unchanged - vn_read/write() now authorize MAC using active_cred but VOP_READ/WRITE() with fp->f_cred Modify vn_rdwr() to accept two credential arguments instead of a single credential: active_cred and file_cred. Use active_cred for MAC authorization, and select a credential for use in VOP_READ/WRITE() based on whether file_cred is NULL or not. If file_cred is provided, authorize the VOP using that cred, otherwise the active credential, matching current semantics. Modify current vn_rdwr() consumers to pass a file_cred if used in the context of a struct file, and to always pass active_cred. When vn_rdwr() is used without a file_cred, pass NOCRED. These changes should maintain current semantics for read/write, but avoid a redundant passing of fp->f_cred, as well as making it more clear what the origin of each credential is in file descriptor read/write operations. Follow-up commits will make similar changes to other file descriptor operations, and modify the MAC framework to pass both credentials to MAC policy modules so they can implement either semantic for revocation. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=101941
* - Hold the vnode lock throughout execve.Jeff Roberson2002-08-131-10/+3
| | | | | | | | - Set VV_TEXT in the top level execve code. - Fixup the image activators to deal with the newly locked vnode. Notes: svn path=/head/; revision=101771
* - Replace v_flag with v_iflag and v_vflagJeff Roberson2002-08-041-5/+7
| | | | | | | | | | | | | | | | | | - v_vflag is protected by the vnode lock and is used when synchronization with VOP calls is needed. - v_iflag is protected by interlock and is used for dealing with vnode management issues. These flags include X/O LOCK, FREE, DOOMED, etc. - All accesses to v_iflag and v_vflag have either been locked or marked with mp_fixme's. - Many ASSERT_VOP_LOCKED calls have been added where the locking was not clear. - Many functions in vfs_subr.c were restructured to provide for stronger locking. Idea stolen from: BSD/OS Notes: svn path=/head/; revision=101308
* Infrastructure tweaks to allow having both an Elf32 and an Elf64 executablePeter Wemm2002-07-201-142/+313
| | | | | | | | | | | | | | | | | | 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). Notes: svn path=/head/; revision=100384
* Clean up execve locking:Jeff Roberson2002-07-061-4/+11
| | | | | | | | | - 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 Notes: svn path=/head/; revision=99487
* Fix typo in the BSD copyright: s/withough/without/Jens Schweikhardt2002-06-021-1/+1
| | | | | | | | Spotted and suggested by: des MFC after: 3 weeks Notes: svn path=/head/; revision=97748
* Remove __P.Alfred Perlstein2002-03-191-19/+18
| | | | Notes: svn path=/head/; revision=92723
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredJohn Baldwin2002-02-271-1/+1
| | | | | | | reference. Notes: svn path=/head/; revision=91406
* Remove whitespace at end of line.Mark Peek2001-12-161-1/+1
| | | | Notes: svn path=/head/; revision=88021
* Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loaderPaul Saab2001-10-101-2/+0
| | | | | | | | | | tunable. Reviewed by: peter MFC after: 2 weeks Notes: svn path=/head/; revision=84783
* Make uio_yield() a global. Call uio_yield() between chunksMatthew Dillon2001-09-261-2/+2
| | | | | | | | | | | | | | | | | in vn_rdwr_inchunks(), allowing other processes to gain an exclusive lock on the vnode. Specifically: directory scanning, to avoid a race to the root directory, and multiple child processes coring simultaniously so they can figure out that some other core'ing child has an exclusive adv lock and just exit instead. This completely fixes performance problems when large programs core. You can have hundreds of copies (forked children) of the same binary core all at once and not notice. MFC after: 3 days Notes: svn path=/head/; revision=83959
* KSE Milestone 2Julian Elischer2001-09-121-13/+19
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* This brings in a Yahoo coredump patch from Paul, with additional mods byMatthew Dillon2001-09-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | me (addition of vn_rdwr_inchunks). The problem Yahoo is solving is that if you have large process images core dumping, or you have a large number of forked processes all core dumping at the same time, the original coredump code would leave the vnode locked throughout. This can cause the directory vnode to get locked up, which can cause the parent directory vnode to get locked up, and so on all the way to the root node, locking the entire machine up for extremely long periods of time. This patch solves the problem in two ways. First it uses an advisory non-blocking lock to abort multiple processes trying to core to the same file. Second (my contribution) it chunks up the writes and uses bwillwrite() to avoid holding the vnode locked while blocking in the buffer cache. Submitted by: ps Reviewed by: dillon MFC after: 2 weeks Notes: svn path=/head/; revision=83222
* For ia64, set the default elf brand to be FreeBSD. This is temporarilyPeter Wemm2001-09-021-0/+4
| | | | | | | necessary only for as long as we're using a linux toolchain. Notes: svn path=/head/; revision=82789
* OR M_WAITOK with M_ZERO in malloc()s args for clarity.Brian Somers2001-08-281-1/+1
| | | | Notes: svn path=/head/; revision=82477
* Unbreak linux compatibility by providing the correct length of the buffer.Mark Peek2001-08-181-1/+1
| | | | | | | | | Reported by: "Pierre Y. Dampure" <pierre.dampure@westmarsh.com>, "Niels Chr. Bank-Pedersen" <ncbp@bank-pedersen.dk> Pointy hat to: mp Notes: svn path=/head/; revision=81881
* Don't explicitly null-terminate. The buffer we are copying into isPeter Wemm2001-08-161-1/+0
| | | | | | | | | already zeroed, and we explicitly leave the last byte untouched. Submitted by: bde Notes: svn path=/head/; revision=81799
* Reduce stack allocation (stack-fast?).Mark Peek2001-08-161-40/+65
| | | | | | | | | | | elf_load_file() => 352 to 52 bytes exec_elf_imgact() => 1072 to 48 bytes elf_corehdr() => 396 to 8 bytes Reviewed by: julian Notes: svn path=/head/; revision=81781
* Use explicit sizes for the prpsinfo command length string so thatPeter Wemm2001-08-161-1/+2
| | | | | | | | we dont have any more unexpected changes in core dumps. This gets us back to the original core dump layout from a few days ago. Notes: svn path=/head/; revision=81757
* With Alfred's permission, remove vm_mtx in favor of a fine-grained approachMatthew Dillon2001-07-041-13/+4
| | | | | | | | | | | | (this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant. Notes: svn path=/head/; revision=79224
* Lock the VM while twiddling the vmspace.John Baldwin2001-05-231-1/+2
| | | | Notes: svn path=/head/; revision=77075
* Introduce a global lock for the vm subsystem (vm_mtx).Alfred Perlstein2001-05-191-3/+18
| | | | | | | | | | | | | | | | | | | | | | vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb Notes: svn path=/head/; revision=76827
* Convert the allproc and proctree locks from lockmgr locks to sx locks.John Baldwin2001-03-281-3/+3
| | | | Notes: svn path=/head/; revision=74927
* Catch up to header include changes:John Baldwin2001-03-281-0/+1
| | | | | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h> Notes: svn path=/head/; revision=74914
* Do not set a default ELF syscall ABI fallback.David E. O'Brien2001-03-041-6/+5
| | | | | | | | If one runs an un-branded Linux static binary that calls Linux's fcntl the machine will reboot when interupted by the FreeBSD syscall ABI. Notes: svn path=/head/; revision=73509
* MFS: bring the consistent `compat_3_brand' support into -CURRENTDavid E. O'Brien2001-02-241-8/+12
| | | | | | | | (the work was first done in the RELENG_4 branch near a release during a MFC to make the code cleaner and more consistent) Notes: svn path=/head/; revision=72999
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order) Notes: svn path=/head/; revision=72200
* Back out proc locking to protect p_ucred for obtaining additionalJohn Baldwin2001-01-271-6/+1
| | | | | | | references along with the actual obtaining of additional references. Notes: svn path=/head/; revision=71699
* Proc locking.John Baldwin2001-01-241-1/+6
| | | | Notes: svn path=/head/; revision=71497
* - Change the allproc_lock to use a macro, ALLPROC_LOCK(how), insteadJake Burkholder2000-12-131-2/+2
| | | | | | | | | | | of explicit calls to lockmgr. Also provides macros for the flags pased to specify shared, exclusive or release which map to the lockmgr flags. This is so that the use of lockmgr can be easily replaced with optimized reader-writer locks. - Add some locking that I missed the first time. Notes: svn path=/head/; revision=69947
* Protect the following with a lockmgr lock:Jake Burkholder2000-11-221-3/+8
| | | | | | | | | | | | | | | allproc zombproc pidhashtbl proc.p_list proc.p_hash nextpid Reviewed by: jhb Obtained from: BSD/OS and netbsd Notes: svn path=/head/; revision=69022
* Make MINSIGSTKSZ machine dependent, and have the sigaltstackMarcel Moolenaar2000-11-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | syscall compare against a variable sv_minsigstksz in struct sysentvec as to properly take the size of the machine- and ABI dependent struct sigframe into account. The SVR4 and iBCS2 modules continue to have a minsigstksz of 8192 to preserve behavior. The real values (if different) are not known at this time. Other ABI modules use the real values. The native MINSIGSTKSZ is now defined as follows: Arch MINSIGSTKSZ ---- ----------- alpha 4096 i386 2048 ia64 12288 Reviewed by: mjacob Suggested by: bde Notes: svn path=/head/; revision=68520