aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/imgact_aout.c
Commit message (Collapse)AuthorAgeFilesLines
* sysentvec: add SV_SIGSYS flagKonstantin Belousov2023-10-091-2/+4
| | | | (cherry picked from commit b82b4ae752501469053979393e33bbfa74fbc9d2)
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-251-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 (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* Retire sv_transtrapDmitry Chagin2022-06-171-2/+0
| | | | | | | | Call translate_traps directly from sendsig(). MFC after: 2 weeks (cherry picked from commit eca368ecb6e00e9db7e1c090e98a29439d255895)
* fork: Allow ABI to specify fork return values for child.Dmitry Chagin2022-06-171-0/+2
| | | | | | | | | | | | | | At least Linux x86 ABI's does not use carry bit and expects that the dx register is preserved. For this add a new sv_set_fork_retval hook and call it from cpu_fork(). Add a short comment about touching dx in x86_set_fork_retval(), for more details see phab comments from kib@ and imp@. Reviewed by: kib Differential revision: https://reviews.freebsd.org/D31472 MFC after: 2 weeks (cherry picked from commit de8374df28cc23ce0d893fd96d1ad0a861414154)
* exec: Reimplement stack address randomizationMark Johnston2022-02-161-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 Sponsored by: The FreeBSD Foundation (cherry picked from commit 1811c1e957ee1250b08b3246fc0db37ddf64b736)
* sysent: Add a sv_psstringssz field to struct sysentvecMark Johnston2022-01-311-0/+2
| | | | | | | | | | | The size of the ps_strings structure varies between ABIs, so this is useful for computing the address of the ps_strings structure relative to the top of the stack when stack address randomization is enabled. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 3fc21fdd5f8a4eeb71f43cc6841f59ef1debaf9a)
* vdso for ia32 on amd64Konstantin Belousov2022-01-021-2/+17
| | | | (cherry picked from commit 98c8b6252496e874d337d9a7b565d9037609168f)
* imgact_aout.c: some styleKonstantin Belousov2021-12-101-2/+4
| | | | (cherry picked from commit 290e05dde058b50aec48464d7116a55c7417575e)
* imgact_aout.c: We do not expect the aout support to be portedKonstantin Belousov2021-12-101-1/+1
| | | | (cherry picked from commit 9da5257e1c045220c01979dcdceadcf2867d20f0)
* Do not call FreeBSD-ABI specific code for all ABIsKonstantin Belousov2021-07-211-0/+4
| | | | (cherry picked from commit 28a66fc3da3460850520389971e1194f5327f560)
* Get rid of sv_errtbl and SV_ABI_ERRNO().Edward Tomasz Napierala2020-09-171-4/+0
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26388 Notes: svn path=/head/; revision=365832
* Make ps_strings in struct image_params into a pointer.Brooks Davis2020-04-151-1/+1
| | | | | | | | | | | This is a prepratory commit for D24407. Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA Notes: svn path=/head/; revision=359987
* 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
* Use uintptr_t instead of register_t * for the stack base.John Baldwin2019-12-031-4/+6
| | | | | | | | | | | | | | | | | | | - Use ustringp for the location of the argv and environment strings and allow destp to travel further down the stack for the stackgap and auxv regions. - Update the Linux copyout_strings variants to move destp down the stack as was done for the native ABIs in r263349. - Stop allocating a space for a stack gap in the Linux ABIs. This used to hold translated system call arguments, but hasn't been used since r159992. Reviewed by: kib Tested on: md64 (amd64, i386, linux64), i386 (i386, linux) Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22501 Notes: svn path=/head/; revision=355373
* Switch to use shared vnode locks for text files during image activation.Konstantin Belousov2019-05-051-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | kern_execve() locks text vnode exclusive to be able to set and clear VV_TEXT flag. VV_TEXT is mutually exclusive with the v_writecount > 0 condition. The change removes VV_TEXT, replacing it with the condition v_writecount <= -1, and puts v_writecount under the vnode interlock. Each text reference decrements v_writecount. To clear the text reference when the segment is unmapped, it is recorded in the vm_map_entry backed by the text file as MAP_ENTRY_VN_TEXT flag, and v_writecount is incremented on the map entry removal The operations like VOP_ADD_WRITECOUNT() and VOP_SET_TEXT() check that v_writecount does not contradict the desired change. vn_writecheck() is now racy and its use was eliminated everywhere except access. Atomic check for writeability and increment of v_writecount is performed by the VOP. vn_truncate() now increments v_writecount around VOP_SETATTR() call, lack of which is arguably a bug on its own. nullfs bypasses v_writecount to the lower vnode always, so nullfs vnode has its own v_writecount correct, and lower vnode gets all references, since object->handle is always lower vnode. On the text vnode' vm object dealloc, the v_writecount value is reset to zero, and deadfs vop_unset_text short-circuit the operation. Reclamation of lowervp always reclaims all nullfs vnodes referencing lowervp first, so no stray references are left. Reviewed by: markj, trasz Tested by: mjg, pho Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D19923 Notes: svn path=/head/; revision=347151
* Remove sv_pagesize, originally introduced with r100384.Edward Tomasz Napierala2019-03-011-2/+0
| | | | | | | | | | | | | | | | In all of the architectures we have today, we always use PAGE_SIZE. While in theory one could define different things, none of the current architectures do, even the ones that have transitioned from 32-bit to 64-bit like i386 and arm. Some ancient mips binaries on other systems used 8k instead of 4k, but we don't support running those and likely never will due to their age and obscurity. Reviewed by: imp (who also contributed the commit message) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D19280 Notes: svn path=/head/; revision=344705
* Remove iBCS2, part2: general kernelMateusz Guzik2018-12-191-2/+0
| | | | | | | | Reviewed by: kib (previous version) Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=342243
* i386 4/4G split.Konstantin Belousov2018-04-131-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change makes the user and kernel address spaces on i386 independent, giving each almost the full 4G of usable virtual addresses except for one PDE at top used for trampoline and per-CPU trampoline stacks, and system structures that must be always mapped, namely IDT, GDT, common TSS and LDT, and process-private TSS and LDT if allocated. By using 1:1 mapping for the kernel text and data, it appeared possible to eliminate assembler part of the locore.S which bootstraps initial page table and KPTmap. The code is rewritten in C and moved into the pmap_cold(). The comment in vmparam.h explains the KVA layout. There is no PCID mechanism available in protected mode, so each kernel/user switch forth and back completely flushes the TLB, except for the trampoline PTD region. The TLB invalidations for userspace becomes trivial, because IPI handlers switch page tables. On the other hand, context switches no longer need to reload %cr3. copyout(9) was rewritten to use vm_fault_quick_hold(). An issue for new copyout(9) is compatibility with wiring user buffers around sysctl handlers. This explains two kind of locks for copyout ptes and accounting of the vslock() calls. The vm_fault_quick_hold() AKA slow path, is only tried after the 'fast path' failed, which temporary changes mapping to the userspace and copies the data to/from small per-cpu buffer in the trampoline. If a page fault occurs during the copy, it is short-circuit by exception.s to not even reach C code. The change was motivated by the need to implement the Meltdown mitigation, but instead of KPTI the full split is done. The i386 architecture already shows the sizing problems, in particular, it is impossible to link clang and lld with debugging. I expect that the issues due to the virtual address space limits would only exaggerate and the split gives more liveness to the platform. Tested by: pho Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 month Differential revision: https://reviews.freebsd.org/D14633 Notes: svn path=/head/; revision=332489
* Use C99 designated initializers for struct execswEd Maste2018-03-131-1/+4
| | | | | | | It it makes use slightly more clear and facilitates grepping. Notes: svn path=/head/; revision=330842
* sys/kern: 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=326271
* Revert r323722. A better fix will be committed shortly, as well asKonstantin Belousov2017-09-281-17/+0
| | | | | | | | | | | | | | | | | | | | | | some still useful bits of the reverted revision. The problem with the committed fix is that there are still issues with returning from NMI, when NMI interrupted kernel in a moment where the kernel segments selectors were still not loaded into registers. If this happens, the NMI return would loose the userspace selectors because r323722 does not reload segment registers on return to kernel mode. Fixing the problem is complicated. Since an alternative approach to handle the original bug exists, it makes sence to stop adding more complexity. Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=324078
* Fix handling of the segment registers on i386.Konstantin Belousov2017-09-181-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suppose that userspace is executing with the non-standard segment descriptors. Then, until exception or interrupt handler executed SET_KERNEL_SEGS, kernel is still executing with user %ds, %es and %fs. If an interrupt occurs in this window, the interrupt handler is executed unsafely, relying on usability of the usermode registers. If the interrupt results in the context switch on return, the contamination of the kernel state spreads to the thread we switched to. As result, kernel data accesses might fault or, if only the base is changed, completely messed up. More, if the user segment was allocated in LDT, another thread might mark the descriptor as invalid before doreti code tried to reload them. In this case kernel panics. The issue exists for all exception entry points which use trap gate, and thus do not automatically disable interrupts on entry, and for lcall_handler. Fix is two-fold: first, we need to disable interrupts for all kernel entries, changing the IDT descriptor types from trap gate to interrupt gate. Interrupts are re-enabled not earlier than the kernel segments are loaded into the segment registers. Second, we only load the segment registers from the trap frame when returning to usermode. For the later, all interrupt return paths must happen through the doreti common code. There is no way to disable interrupts on call gate, which is the supposed mode of servicing for lcall $7,$0 syscalls. Change the LDT descriptor 0 into a code segment type and point it to the userspace trampoline which redirects the syscall to int $0x80. All the measures make the segment register handling similar to that of amd64. We do not apply amd64 optimizations of not reloading segment registers on return from the syscall. Reported by: Maxime Villard <max@m00nbsd.net> Tested by: pho (the non-lcall part) Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D12402 Notes: svn path=/head/; revision=323722
* Implement vsyscall hack. Prior to 2.13 glibc uses vsyscallDmitry Chagin2016-01-091-0/+1
| | | | | | | | | | | | instead of vdso. An upcoming linux_base-c6 needs it. Differential Revision: https://reviews.freebsd.org/D1090 Reviewed by: kib, trasz MFC after: 1 week Notes: svn path=/head/; revision=293613
* Remove sv_prepsyscall, sv_sigsize and sv_sigtbl members of the structKonstantin Belousov2015-11-281-6/+0
| | | | | | | | | | | | | | | | | | | sysent. sv_prepsyscall is unused. sv_sigsize and sv_sigtbl translate signal number from the FreeBSD namespace into the ABI domain. It is only utilized on i386 for iBCS2 binaries. The issue with this approach is that signals for iBCS2 were delivered with the FreeBSD signal frame layout, which does not follow iBCS2. The same note is true for any other potential user if sv_sigtbl. In other words, if ABI needs signal number translation, it really needs custom sv_sendsig method instead. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=291420
* 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
* In preparation for switching linuxulator to the use the native 1:1Dmitry Chagin2015-05-241-0/+1
| | | | | | | | | threads add a hook for cleaning thread resources before the thread die. Differential Revision: https://reviews.freebsd.org/D1038 Notes: svn path=/head/; revision=283382
* Cosmetics: define FREEBSD32_MINUSER and AOUT32_MINUSER for structKonstantin Belousov2012-07-221-1/+2
| | | | | | | | | | sysentvec .sv_minuser. Also improve style. Submitted by: Oliver Pinter <oliver.pinter@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=238687
* Remove an old hack I noticed years ago, but never committed.Warner Losh2012-06-281-5/+5
| | | | Notes: svn path=/head/; revision=237694
* Do not trash the argv[0] pointer for an a.out process on amd64.Konstantin Belousov2011-06-161-1/+1
| | | | | | | Found with the binary provided by joerg. Notes: svn path=/head/; revision=223165
* Fix silly typo that resulted in the a.out process stack to end atKonstantin Belousov2011-06-161-1/+1
| | | | | | | ~200MB instead of 3GB on amd64. Notes: svn path=/head/; revision=223164
* 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
* Add support for executing the FreeBSD 1/i386 a.out binaries on amd64.Konstantin Belousov2011-04-011-14/+69
| | | | | | | | | | | | | | | | | | In particular: - implement compat shims for old stat(2) variants and ogetdirentries(2); - implement delivery of signals with ancient stack frame layout and corresponding sigreturn(2); - implement old getpagesize(2); - provide a user-mode trampoline and LDT call gate for lcall $7,$0; - port a.out image activator and connect it to the build as a module on amd64. The changes are hidden under COMPAT_43. MFC after: 1 month Notes: svn path=/head/; revision=220238
* Extend struct sysvec with new method sv_schedtail, which is used for anDmitry Chagin2011-03-081-0/+1
| | | | | | | | | | | | | | | | | | explicit process at fork trampoline path instead of eventhadler(schedtail) invocation for each child process. Remove eventhandler(schedtail) code and change linux ABI to use newly added sysvec method. While here replace explicit comparing of module sysentvec structure with the newly created process sysentvec to detect the linux ABI. Discussed with: kib MFC after: 2 Week Notes: svn path=/head/; revision=219405
* Reorganize syscall entry and leave handling.Konstantin Belousov2010-05-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend struct sysvec with three new elements: sv_fetch_syscall_args - the method to fetch syscall arguments from usermode into struct syscall_args. The structure is machine-depended (this might be reconsidered after all architectures are converted). sv_set_syscall_retval - the method to set a return value for usermode from the syscall. It is a generalization of cpu_set_syscall_retval(9) to allow ABIs to override the way to set a return value. sv_syscallnames - the table of syscall names. Use sv_set_syscall_retval in kern_sigsuspend() instead of hardcoding the call to cpu_set_syscall_retval(). The new functions syscallenter(9) and syscallret(9) are provided that use sv_*syscall* pointers and contain the common repeated code from the syscall() implementations for the architecture-specific syscall trap handlers. Syscallenter() fetches arguments, calls syscall implementation from ABI sysent table, and set up return frame. The end of syscall bookkeeping is done by syscallret(). Take advantage of single place for MI syscall handling code and implement ptrace_lwpinfo pl_flags PL_FLAG_SCE, PL_FLAG_SCX and PL_FLAG_EXEC. The SCE and SCX flags notify the debugger that the thread is stopped at syscall entry or return point respectively. The EXEC flag augments SCX and notifies debugger that the process address space was changed by one of exec(2)-family syscalls. The i386, amd64, sparc64, sun4v, powerpc and ia64 syscall()s are changed to use syscallenter()/syscallret(). MIPS and arm are not converted and use the mostly unchanged syscall() implementation. Reviewed by: jhb, marcel, marius, nwhitehorn, stas Tested by: marcel (ia64), marius (sparc64), nwhitehorn (powerpc), stas (mips) MFC after: 1 month Notes: svn path=/head/; revision=208453
* Add sv_flags field to struct sysentvec with intention to provide descriptionKonstantin Belousov2008-11-221-1/+7
| | | | | | | | | | | of the ABI of the currently executing image. Change some places to test the flags instead of explicit comparing with address of known sysentvec structures to determine ABI features. Discussed with: dchagin, imp, jhb, peter Notes: svn path=/head/; revision=185169
* Change the static struct sysentvec and struct Elf_Brandinfo initializersKonstantin Belousov2008-09-241-26/+27
| | | | | | | | | | | | | | to the C99 style. At least, it is easier to read sysent definitions that way, and search for the actual instances of sigcode etc. Explicitely initialize sysentvec.sv_maxssiz that was missed in most sysvecs. No objection from: jhb MFC after: 1 month Notes: svn path=/head/; revision=183322
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inAttilio Rao2008-01-131-1/+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-3/+2
| | | | | | | | | | | | | | | | | | | 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
* Correct two vm object reference leaks in error cases.Alan Cox2006-03-161-0/+2
| | | | | | | Submitted by: davidxu Notes: svn path=/head/; revision=156766
* Maintain the lock on the vnode for most of exec_elfN_imgact().Alan Cox2005-12-241-2/+13
| | | | | | | | | | | | | | | | Specifically, it is required for the I/O that may be performed by elfN_load_section(). Avoid an obscure deadlock in the a.out, elf, and gzip image activators. Add a comment describing why the deadlock does not occur in the common case and how it might occur in less usual circumstances. Eliminate an unused variable from exec_aout_imgact(). In collaboration with: tegge Notes: svn path=/head/; revision=153698
* - Neither of our image formats require Giant now that the vm and vfs haveJeff Roberson2005-05-031-2/+0
| | | | | | | been locked. Notes: svn path=/head/; revision=145819
* o Split out kernel part of execve(2) syscall into two parts: one thatMaxim Sobolev2005-01-291-6/+1
| | | | | | | | | | | | | | 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
* /* -> /*- for copyright notices, minor format tweaks as necessaryWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139804
* Axe a.out core dump support. Neither older gdb binaries nor currentDavid Schultz2004-11-271-54/+1
| | | | | | | bfd sources understand the present format. Notes: svn path=/head/; revision=138128
* Maintain the broken state of backwards compatibilty for a.out (andDavid Schultz2004-11-201-2/+3
| | | | | | | | | | PECOFF!) core dumps. None of the old versions of gdb I tried were able to read a.out core dumps before or after this change. Reviewed by: arch@ Notes: svn path=/head/; revision=137921
* Change the types of vn_rdwr_inchunks()'s len and aresid arguments toTim J. Robbins2004-06-051-1/+1
| | | | | | | | | size_t and size_t *, respectively. Update callers for the new interface. This is a better fix for overflows that occurred when dumping segments larger than 2GB to core files. Notes: svn path=/head/; revision=130101
* Locking for the per-process resource limits structure.John Baldwin2004-02-041-3/+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
* Add sysentvec->sv_fixlimits() hook so that we can catch cases on 64 bitPeter Wemm2003-09-251-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | systems where the data/stack/etc limits are too big for a 32 bit process. Move the 5 or so identical instances of ELF_RTLD_ADDR() into imgact_elf.c. Supply an ia32_fixlimits function. Export the clip/default values to sysctl under the compat.ia32 heirarchy. Have mmap(0, ...) respect the current p->p_limits[RLIMIT_DATA].rlim_max value rather than the sysctl tweakable variable. This allows mmap to place mappings at sensible locations when limits have been reduced. Have the imgact_elf.c ld-elf.so.1 placement algorithm use the same method as mmap(0, ...) now does. Note that we cannot remove all references to the sysctl tweakable maxdsiz etc variables because /etc/login.conf specifies a datasize of 'unlimited'. And that causes exec etc to fail since it can no longer find space to mmap things. Notes: svn path=/head/; revision=120422