aboutsummaryrefslogtreecommitdiff
path: root/sys/i386/linux/imgact_linux.c
Commit message (Collapse)AuthorAgeFilesLines
* linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743Dmitry Chagin2023-08-181-1/+0
|
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* exec: Reimplement stack address randomizationMark Johnston2022-01-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The approach taken by the stack gap implementation was to insert a random gap between the top of the fixed stack mapping and the true top of the main process stack. This approach was chosen so as to avoid randomizing the previously fixed address of certain process metadata stored at the top of the stack, but had some shortcomings. In particular, mlockall(2) calls would wire the gap, bloating the process' memory usage, and RLIMIT_STACK included the size of the gap so small (< several MB) limits could not be used. There is little value in storing each process' ps_strings at a fixed location, as only very old programs hard-code this address; consumers were converted decades ago to use a sysctl-based interface for this purpose. Thus, this change re-implements stack address randomization by simply breaking the convention of storing ps_strings at a fixed location, and randomizing the location of the entire stack mapping. This implementation is simpler and avoids the problems mentioned above, while being unlikely to break compatibility anywhere the default ASLR settings are used. The kern.elfN.aslr.stack_gap sysctl is renamed to kern.elfN.aslr.stack, and is re-enabled by default. PR: 260303 Reviewed by: kib Discussed with: emaste, mw MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33704
* vm_map_protect: allow to set prot and max_prot in one go.Konstantin Belousov2021-01-121-2/+4
| | | | | | | | | | | | | | This prevents a situation where other thread modifies map entries permissions between setting max_prot, then relocking, then setting prot, confusing the operation outcome. E.g. you can get an error that is not possible if operation is performed atomic. Also enable setting rwx for max_prot even if map does not allow to set effective rwx protection. Reviewed by: brooks, markj (previous version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28117
* vfs: drop the mostly unused flags argument from VOP_UNLOCKMateusz Guzik2020-01-031-1/+1
| | | | | | | | | | | Filesystems which want to use it in limited capacity can employ the VOP_UNLOCK_FLAGS macro. Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D21427 Notes: svn path=/head/; revision=356337
* imgact_linux.c: use standard indentationEd Maste2018-03-121-146/+136
| | | | | | | Sponsored by: Turing Robotic Industries Inc. Notes: svn path=/head/; revision=330822
* Linuxulator: apply style(9) to returnEd Maste2018-03-121-1/+1
| | | | | | | Sponsored by: Turing Robotic Industries Inc. Notes: svn path=/head/; revision=330798
* Correct proper nouns in the LinuxulatorEd Maste2018-02-221-1/+1
| | | | | | | | | | | - Capitalize Linux - Spell FreeBSD out in full - Address some style(9) on changed lines Sponsored by: Turing Robotic Industries Inc. Notes: svn path=/head/; revision=329794
* Rationalize license text on Linuxolator filesEd Maste2018-02-161-15/+13
| | | | | | | | | | | | | | | Many licenses on Linuxolator files contained small variations from the standard FreeBSD license text. To avoid license proliferation switch to the standard 2-clause FreeBSD license for those files where I have permission from each of the listed copyright holders. Additional files waiting on permission from others are listed in review D14210. Approved by: kan, marcel, sos, rdivacky MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=329370
* sys/i386: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326260
* Implement lockless resource limits.Mateusz Guzik2015-06-101-1/+1
| | | | | | | | | | | | | Use the same scheme implemented to manage credentials. Code needing to look at process's credentials (as opposed to thred's) is provided with *_proc variants of relevant functions. Places which possibly had to take the proc lock anyway still use the proc pointer to access limits. Notes: svn path=/head/; revision=284215
* Add a mmap flag (MAP_32BIT) on 64-bit platforms to request that a mapping useJohn Baldwin2013-09-091-3/+3
| | | | | | | | | | | | | | | | an address in the first 2GB of the process's address space. This flag should have the same semantics as the same flag on Linux. To facilitate this, add a new parameter to vm_map_find() that specifies an optional maximum virtual address. While here, fix several callers of vm_map_find() to use a VMFS_* constant for the findspace argument instead of TRUE and FALSE. Reviewed by: alc Approved by: re (kib) Notes: svn path=/head/; revision=255426
* Fix misuse of the kernel map in miscellaneous image activators.Konstantin Belousov2012-02-171-16/+10
| | | | | | | | | | | | | | | | | | | | | | Vnode-backed mappings cannot be put into the kernel map, since it is a system map. Use exec_map for transient mappings, and remove the mappings with kmem_free_wakeup() to notify the waiters on available map space. Do not map the whole executable into KVA at all to copy it out into usermode. Directly use vn_rdwr() for the case of not page aligned binary. There is one place left where the potentially unbounded amount of data is mapped into exec_map, namely, in the COFF image activator enumeration of the needed shared libraries. Reviewed by: alc MFC after: 2 weeks Notes: svn path=/head/; revision=231885
* Convert files to UTF-8Ulrich Spörlein2012-01-151-1/+1
| | | | Notes: svn path=/head/; revision=230132
* Add accounting for most of the memory-related resources.Edward Tomasz Napierala2011-04-051-1/+3
| | | | | | | | Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Notes: svn path=/head/; revision=220373
* Setting VV_TEXT here is redundant. It is already set by do_execve().Alan Cox2011-02-091-3/+0
| | | | | | | Reviewed by: kib Notes: svn path=/head/; revision=218493
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inAttilio Rao2008-01-131-2/+1
| | | | | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com> Notes: svn path=/head/; revision=175294
* vn_lock() is currently only used with the 'curthread' passed as argument.Attilio Rao2008-01-101-1/+1
| | | | | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com> Notes: svn path=/head/; revision=175202
* Fix for the panic("vm_thread_new: kstack allocation failed") andKonstantin Belousov2007-11-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | | silent NULL pointer dereference in the i386 and sparc64 pmap_pinit() when the kmem_alloc_nofault() failed to allocate address space. Both functions now return error instead of panicing or dereferencing NULL. As consequence, vmspace_exec() and vmspace_unshare() returns the errno int. struct vmspace arg was added to vm_forkproc() to avoid dealing with failed allocation when most of the fork1() job is already done. The kernel stack for the thread is now set up in the thread_alloc(), that itself may return NULL. Also, allocation of the first process thread is performed in the fork1() to properly deal with stack allocation failure. proc_linkup() is separated into proc_linkup() called from fork1(), and proc_linkup0(), that is used to set up the kernel process (was known as swapper). In collaboration with: Peter Holm Reviewed by: jhb Notes: svn path=/head/; revision=173361
* Partial MFp4 of 114977:Alexander Leidinger2007-02-241-1/+1
| | | | | | | | | Whitespace commit: Fix grammar, spelling and punctuation. Submitted by: "Scot Hetzel" <swhetzel@gmail.com> Notes: svn path=/head/; revision=166944
* - Change the vm_mmap() function to accept an objtype_t parameter specifyingJohn Baldwin2005-04-011-3/+4
| | | | | | | | | | | | | | | the type of object represented by the handle argument. - Allow vm_mmap() to map device memory via cdev objects in addition to vnodes and anonymous memory. Note that mmaping a cdev directly does not currently perform any MAC checks like mapping a vnode does. - Unbreak the DRM getbufs ioctl by having it call vm_mmap() directly on the cdev the ioctl is acting on rather than trying to find a suitable vnode to map from. Reviewed by: alc, arch@ Notes: svn path=/head/; revision=144501
* o Split out kernel part of execve(2) syscall into two parts: one thatMaxim Sobolev2005-01-291-5/+0
| | | | | | | | | | | | | | copies arguments into the kernel space and one that operates completely in the kernel space; o use kernel-only version of execve(2) to kill another stackgap in linuxlator/i386. Obtained from: DragonFlyBSD (partially) MFC after: 2 weeks Notes: svn path=/head/; revision=140992
* Add casts so all these quantities are a constant type.David E. O'Brien2004-06-241-1/+1
| | | | Notes: svn path=/head/; revision=131014
* Locking for the per-process resource limits structure.John Baldwin2004-02-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - struct plimit includes a mutex to protect a reference count. The plimit structure is treated similarly to struct ucred in that is is always copy on write, so having a reference to a structure is sufficient to read from it without needing a further lock. - The proc lock protects the p_limit pointer and must be held while reading limits from a process to keep the limit structure from changing out from under you while reading from it. - Various global limits that are ints are not protected by a lock since int writes are atomic on all the archs we support and thus a lock wouldn't buy us anything. - All accesses to individual resource limits from a process are abstracted behind a simple lim_rlimit(), lim_max(), and lim_cur() API that return either an rlimit, or the current or max individual limit of the specified resource from a process. - dosetrlimit() was renamed to kern_setrlimit() to match existing style of other similar syscall helper functions. - The alpha OSF/1 compat layer no longer calls getrlimit() and setrlimit() (it didn't used the stackgap when it should have) but uses lim_rlimit() and kern_setrlimit() instead. - The svr4 compat no longer uses the stackgap for resource limits calls, but uses lim_rlimit() and kern_setrlimit() instead. - The ibcs2 compat no longer uses the stackgap for resource limits. It also no longer uses the stackgap for accessing sysctl's for the ibcs2_sysconf() syscall but uses kernel_sysctl() instead. As a result, ibcs2_sysconf() no longer needs Giant. - The p_rlimit macro no longer exists. Submitted by: mtm (mostly, I only did a few cleanups and catchups) Tested on: i386 Compiled on: alpha, amd64 Notes: svn path=/head/; revision=125454
* Restored non-egregious casts so that this file compiles on i386's withBruce Evans2003-09-071-3/+4
| | | | | | | 64-bit longs again. Notes: svn path=/head/; revision=119842
* Use __FBSDID().David E. O'Brien2003-06-021-2/+3
| | | | Notes: svn path=/head/; revision=115705
* Clean up whitespace and remove register keyword.Dag-Erling Smørgrav2003-03-031-14/+14
| | | | Notes: svn path=/head/; revision=111798
* More caddr_t removal, in conjunction with copy{in,out}(9) this time.Dag-Erling Smørgrav2003-03-031-5/+4
| | | | | | | Also clean up some egregious casts and incorrect use of sizeof. Notes: svn path=/head/; revision=111797
* Style(9). Make some function declarations consistent with the rest,Mark Murray2002-10-191-2/+1
| | | | | | | and remove some nearby extraneous {}'s. Notes: svn path=/head/; revision=105441
* Use the fields in the sysentvec and in the vm map header in place of theJake Burkholder2002-09-211-1/+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
* - Hold the vnode lock throughout execve.Jeff Roberson2002-08-131-9/+15
| | | | | | | | - 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-1/+2
| | | | | | | | | | | | | | | | | | - 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-1/+1
| | | | | | | | | | | | | | | | | | 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
* 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-201-1/+1
| | | | Notes: svn path=/head/; revision=92765
* Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loaderPaul Saab2001-10-101-1/+1
| | | | | | | | | | tunable. Reviewed by: peter MFC after: 2 weeks Notes: svn path=/head/; revision=84783
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inMark Murray2001-05-011-2/+3
| | | | | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations) Notes: svn path=/head/; revision=76166
* Proc locking.John Baldwin2001-01-241-0/+1
| | | | Notes: svn path=/head/; revision=71497
* Fix #! script exec under linux emulation. If a script is exec'd from aMatthew Dillon2000-04-261-2/+0
| | | | | | | | | | | | | program running under linux emulation, the script binary is checked for in /compat/linux first. Without this patch the wrong script binary (i.e. the FreeBSD binary) will be run instead of the linux binary. For example, #!/bin/sh, thus breaking out of linux compatibility mode. This solves a number of problems people have had installing linux software on FreeBSD boxes. Notes: svn path=/head/; revision=59663
* Implement pluggable ioctl handlers.Marcel Moolenaar1999-12-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Other modules can register and unregister ioctl handlers to extend the ioctls known by the Linuxulator. A recent application is the vmware port. The Linuxulator itself uses the new interface to register its handlers as well. Handlers for the following types of ioctls have been defined: cdrom console (=keyboard and VT handling) socket sound termio All ioctl related defines and declarations have been moved to a new file (linux_ioctl.h), except for the pluggable ioctl handler interface definition. While there, cleanup linux.h some more. linux.h and linux_ioctl.[ch] have been made to conform to style(9) as much as possible. Inspired and reviewed by: Vladimir N. Silyaev Notes: svn path=/head/; revision=54122
* useracc() the prequel:Poul-Henning Kamp1999-10-291-1/+0
| | | | | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument. Notes: svn path=/head/; revision=52635
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Fix a couple of warnings and some bitrot in comments.Peter Wemm1999-05-091-5/+2
| | | | Notes: svn path=/head/; revision=46803
* Minor cleanup; no more references to LKM's.Peter Wemm1999-01-171-3/+3
| | | | Notes: svn path=/head/; revision=42766
* *gulp*. Jordan specifically OK'ed this..Peter Wemm1998-10-161-2/+2
| | | | | | | | | | | This is the bulk of the support for doing kld modules. Two linker_sets were replaced by SYSINIT()'s. VFS's and exec handlers are self registered. kld is now a superset of lkm. I have converted most of them, they will follow as a seperate commit as samples. This all still works as a static a.out kernel using LKM's. Notes: svn path=/head/; revision=40435
* Use [u]intptr_t instead of [u_]long for casts between pointers andBruce Evans1998-08-161-5/+6
| | | | | | | integers. Don't forget to cast to (void *) as well. Notes: svn path=/head/; revision=38354
* Fixed print format errors.Bruce Evans1998-07-291-6/+9
| | | | Notes: svn path=/head/; revision=37950
* De-staticize enough to make all the LKMs work again. Add comments whereEivind Eklund1998-02-111-3/+3
| | | | | | | deemed relevant. Notes: svn path=/head/; revision=33233
* Staticize.Eivind Eklund1998-02-091-4/+4
| | | | Notes: svn path=/head/; revision=33181