summaryrefslogtreecommitdiffstats
path: root/sys/kern/sysv_shm.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r282213:trasz2015-06-211-13/+17
| | | | | | | | | | | | | | | | | | Add kern.racct.enable tunable and RACCT_DISABLED config option. The point of this is to be able to add RACCT (with RACCT_DISABLED) to GENERIC, to avoid having to rebuild the kernel to use rctl(8). MFC r282901: Build GENERIC with RACCT/RCTL support by default. Note that it still needs to be enabled by adding "kern.racct.enable=1" to /boot/loader.conf. Note those two are MFC-ed together, because the latter one changes the name of RACCT_DISABLED option to RACCT_DEFAULT_TO_DISABLED. Should have committed the renaming separately... Relnotes: yes Sponsored by: The FreeBSD Foundation
* MFC r282084:kib2015-05-041-26/+24
| | | | Fix locking for oshmctl() and shmsys().
* MFC r281094:kib2015-04-071-1/+1
| | | | Restore proper error from oshmctl(2), broken by r280323.
* MFC r281071:kib2015-04-071-1/+1
| | | | Remove useless initialization.
* MFC r280323:kib2015-04-041-255/+212
| | | | | | | Somewhat modernize the SysV shm code. MFC r280325 (by cognet): Fix warning for !MAC case.
* MFC r278697 (by alc):kib2015-04-041-1/+2
| | | | Preset the object's color, or alignment, to maximize superpage usage.
* MFC r258056 (by alc):kib2015-04-041-4/+2
| | | | | | Eliminate the gratuitous use of mmap(2) flags from the implementation of kern_shmat(). Use a simpler approach to determine whether to pass VMFS_NO_SPACE or VMFS_OPTIMAL_SPACE to vm_map_find().
* MFC r278963:kib2015-02-251-5/+16
| | | | | | | If malloc() sleeps, Giant is dropped. Recheck for another thread doing our work. Remove unneeded check for failed M_WAITOK allocation.
* Add a mmap flag (MAP_32BIT) on 64-bit platforms to request that a mapping usejhb2013-09-091-1/+1
| | | | | | | | | | | | | 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)
* Be more aggressive in using superpages in all mappings of objects:jhb2013-07-191-1/+1
| | | | | | | | | | | | | | - Add a new address space allocation method (VMFS_OPTIMAL_SPACE) for vm_map_find() that will try to alter the alignment of a mapping to match any existing superpage mappings of the object being mapped. If no suitable address range is found with the necessary alignment, vm_map_find() will fall back to using the simple first-fit strategy (VMFS_ANY_SPACE). - Change mmap() without MAP_FIXED, shmat(), and the GEM mapping ioctl to use VMFS_OPTIMAL_SPACE instead of VMFS_ANY_SPACE. Reviewed by: alc (earlier version) MFC after: 2 weeks
* Rename VM_OBJECT_LOCK(), VM_OBJECT_UNLOCK() and VM_OBJECT_TRYLOCK() toattilio2013-02-201-2/+2
| | | | | | their "write" versions. Sponsored by: EMC / Isilon storage division
* Switch vm_object lock to be a rwlock.attilio2013-02-201-0/+1
| | | | | | | | * VM_OBJECT_LOCK and VM_OBJECT_UNLOCK are mapped to write operations * VM_OBJECT_SLEEP() is introduced as a general purpose primitve to get a sleep operation using a VM_OBJECT_LOCK() as protection * The approach must bear with vm_pager.h namespace pollution so many files require including directly rwlock.h
* Close a race due to dropping of the map lock between creating a map entryalc2012-02-191-3/+1
| | | | | | | for a shared mapping and marking the entry for inheritance. Reviewed by: kib X-MFC after: r231526
* Allow to set kern.ipc.shmmax from /boot/loader.conf.pjd2012-02-081-7/+7
| | | | MFC after: 1 week
* In order to maximize the re-usability of kernel code in user space thiskmacy2011-09-161-11/+11
| | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz)
* All the racct_*() calls need to happen with the proc locked. Fixing thistrasz2011-07-061-0/+4
| | | | | | won't happen before 9.0. This commit adds "#ifdef RACCT" around all the "PROC_LOCK(p); racct_whatever(p, ...); PROC_UNLOCK(p)" instances, in order to avoid useless locking/unlocking in kernels built without "options RACCT".
* Style fix.trasz2011-04-061-2/+1
| | | | Submitted by: jhb@
* Add accounting for SysV-related resources.trasz2011-04-061-1/+20
| | | | | Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version)
* Add ucred pointer to the SysV-related memory structures. This is requiredtrasz2011-04-061-0/+4
| | | | | | | | | | for racct. Note that after this commit, ipcs(1) needs to be rebuilt. Otherwise, it will fail with "ipcs: sysctlbyname: kern.ipc.msqids: Cannot allocate memory". Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version)
* Add some FEATURE macros for various features (AUDIT/CAM/IPC/KTR/MAC/NFS/NTP/netchild2011-02-251-0/+2
| | | | | | | | | | | | | PMC/SYSV/...). No FreeBSD version bump, the userland application to query the features will be committed last and can serve as an indication of the availablility if needed. Sponsored by: Google Summer of Code 2010 Submitted by: kibab Reviewed by: arch@ (parts by rwatson, trasz, jhb) X-MFC after: to be determined in last commit with code from this project
* Specify a CTLTYPE_FOO so that a future sysctl(8) change does not needmdf2011-01-181-1/+1
| | | | to rely on the format string.
* Remove useless NULL checks for M_WAITOK mallocs.trasz2010-12-021-2/+0
|
* If i is going to be used in the loop unconditionally the declarationdougb2010-06-291-2/+0
| | | | | | has to be unconditional as well. Conical head covering to: kib
* Despite system call deregistration drains the threads executing System Vkib2010-06-281-1/+9
| | | | | | | | | | | | | | | | shm syscalls, and initial check for the number of allocated segments in the module deinitialization code, the following might happen: after the check for active segment, while waiting for threads to leave some other syscall, shmget(2) is called. Then, we can end up with the shared segment that cannot be detached since sysvshm module is unloaded. Prevent the leak by rechecking and disclaiming a reference to the vm object owned by sysvshm module, that might have grown during the drain. Tested by: pho Reviewed by: jhb MFC after: 1 month
* In another move to join with the age of the Fruitbat, increase SYSVivoras2010-06-111-1/+1
| | | | | | | | | | | shared resources defaults beyond absolute minimums. The new values are chosen mostly by magic. They are still fairly small and will need increasing for large installations (especially SHMMAX). However, they are now enough to e.g. start PostgreSQL installations with ~~300 users and nearly 512 MB of shared buffers. Reviewed by: A short discussion on hackers@
* Move SysV IPC freebsd32 compat shims from freebsd32_misc.c to correspondingkib2010-03-191-15/+280
| | | | | | | | | | | | | | sysv_{msg,sem,shm}.c files. Mark SysV IPC freebsd32 syscalls as NOSTD and add required SYSCALL_INIT_HELPER/SYSCALL32_INIT_HELPERs to provide auto register/unregister on module load. This makes COMPAT_FREEBSD32 functional with SysV IPC compiled and loaded as modules. Reviewed by: jhb MFC after: 2 weeks
* - Rename tunable kern.ipc.shmmaxpgs to kern.ipc.shmall.ru2009-10-241-1/+8
| | | | | | - Explain the fuss when initializing shmmax. PR: 75542 (mistakenly closed instead of PR 75541)
* Use the correct cast for the arguments passed to freebsd_shmctl() injhb2009-06-251-1/+1
| | | | | | oshmctl(). Submitted by: kib
* Tweak the oshmctl() compile fix: convert the K&R definition to ANSI.jhb2009-06-251-7/+1
|
* oshmctl() now requires a sysv_shm.c-local function prototype.rwatson2009-06-251-0/+4
|
* Change the ABI of some of the structures used by the SYSV IPC API:jhb2009-06-241-12/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The uid/cuid members of struct ipc_perm are now uid_t instead of unsigned short. - The gid/cgid members of struct ipc_perm are now gid_t instead of unsigned short. - The mode member of struct ipc_perm is now mode_t instead of unsigned short (this is merely a style bug). - The rather dubious padding fields for ABI compat with SV/I386 have been removed from struct msqid_ds and struct semid_ds. - The shm_segsz member of struct shmid_ds is now a size_t instead of an int. This removes the need for the shm_bsegsz member in struct shmid_kernel and should allow for complete support of SYSV SHM regions >= 2GB. - The shm_nattch member of struct shmid_ds is now an int instead of a short. - The shm_internal member of struct shmid_ds is now gone. The internal VM object pointer for SHM regions has been moved into struct shmid_kernel. - The existing __semctl(), msgctl(), and shmctl() system call entries are now marked COMPAT7 and new versions of those system calls which support the new ABI are now present. - The new system calls are assigned to the FBSD-1.1 version in libc. The FBSD-1.0 symbols in libc now refer to the old COMPAT7 system calls. - A simplistic framework for tagging system calls with compatibility symbol versions has been added to libc. Version tags are added to system calls by adding an appropriate __sym_compat() entry to src/lib/libc/incldue/compat.h. [1] PR: kern/16195 kern/113218 bin/129855 Reviewed by: arch@, rwatson Discussed with: kan, kib [1]
* Deprecate the msgsys(), semsys(), and shmsys() system calls by movingjhb2009-06-241-115/+106
| | | | | | | | | them under COMPAT_FREEBSD[4567]. Starting with FreeBSD 5.0 the SYSV IPC API was implemented via direct system calls (e.g. msgctl(), msgget(), etc.) rather than indirecting through the var-args *sys() system calls. The shmsys() system call was already effectively deprecated for all but COMPAT_FREEBSD4 already as its implementation for the !COMPAT_FREEBSD4 case was to simply invoke nosys().
* - Move syscall function argument structure types to be just above thejhb2009-06-241-16/+15
| | | | | relevenat system call function. - Whitespace fixes.
* Implement global and per-uid accounting of the anonymous memory. Addkib2009-06-231-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | rlimit RLIMIT_SWAP that limits the amount of swap that may be reserved for the uid. The accounting information (charge) is associated with either map entry, or vm object backing the entry, assuming the object is the first one in the shadow chain and entry does not require COW. Charge is moved from entry to object on allocation of the object, e.g. during the mmap, assuming the object is allocated, or on the first page fault on the entry. It moves back to the entry on forks due to COW setup. The per-entry granularity of accounting makes the charge process fair for processes that change uid during lifetime, and decrements charge for proper uid when region is unmapped. The interface of vm_pager_allocate(9) is extended by adding struct ucred *, that is used to charge appropriate uid when allocation if performed by kernel, e.g. md(4). Several syscalls, among them is fork(2), may now return ENOMEM when global or per-uid limits are enforced. In collaboration with: pho Reviewed by: alc Approved by: re (kensmith)
* Eliminate an instance of VM_PROT_READ_IS_EXEC that I overlooked in r190705.alc2009-06-091-4/+0
|
* Move "options MAC" from opt_mac.h to opt_global.h, as it's now in GENERICrwatson2009-06-051-1/+0
| | | | | | | | and used in a large number of files, but also because an increasing number of incorrect uses of MAC calls were sneaking in due to copy-and-paste of MAC-aware code without the associated opt_mac.h include. Discussed with: pjd
* Add hierarchical jails. A jail may further virtualize its environmentjamie2009-05-271-6/+6
| | | | | | | | | | | | | | | | | | | | | | by creating a child jail, which is visible to that jail and to any parent jails. Child jails may be restricted more than their parents, but never less. Jail names reflect this hierarchy, being MIB-style dot-separated strings. Every thread now points to a jail, the default being prison0, which contains information about the physical system. Prison0's root directory is the same as rootvnode; its hostname is the same as the global hostname, and its securelevel replaces the global securelevel. Note that the variable "securelevel" has actually gone away, which should not cause any problems for code that properly uses securelevel_gt() and securelevel_ge(). Some jail-related permissions that were kept in global variables and set via sysctls are now per-jail settings. The sysctls still exist for backward compatibility, used only by the now-deprecated jail(2) system call. Approved by: bz (mentor)
* Systematically use vm_size_t to specify the size of the segment for VM KPI.kib2009-03-051-6/+6
| | | | | | | | | Do not overload the local variable size in kern_shmat() due to vm_size_t change. Fix style bug by adding explicit comparision with 0. Discussed with: bde MFC after: 1 week
* Correct types of variables used to track amount of allocated SysV sharedkib2009-03-021-7/+11
| | | | | | | | | | | | | | memory from int to size_t. Implement a workaround for current ABI not allowing to properly save size for and report more then 2Gb sized segment of shared memory. This makes it possible to use > 2 Gb shared memory segments on 64bit architectures. Please note the new BUGS section in shmctl(2) and UPDATING note for limitations of this temporal solution. Reviewed by: csjp Tested by: Nikolay Dzham <i levsha org ua> MFC after: 2 weeks
* Make sure we restrict Linux only IPC calls from being executedcsjp2008-02-121-3/+18
| | | | | | | | | | | | | | | | | through the FreeBSD ABI. IPC_INFO, SHM_INFO, SHM_STAT were added specifically for Linux binary support. They are not documented as being a part of the FreeBSD ABI, also, the structures necessary for them have been hidden away from the users for a long time. Also, the Linux ABI layer uses it's own structures to populate the responses back to the user to ensure that the ABI is consistent. I think there is a bit more separation work that needs to happen. Reviewed by: jhb Discussed with: jhb Discussed on: freebsd-arch@ (very briefly) MFC after: 1 month
* Merge first in a series of TrustedBSD MAC Framework KPI changesrwatson2007-10-241-10/+10
| | | | | | | | | | | | | | | | | | | | | | | from Mac OS X Leopard--rationalize naming for entry points to the following general forms: mac_<object>_<method/action> mac_<object>_check_<method/action> The previous naming scheme was inconsistent and mostly reversed from the new scheme. Also, make object types more consistent and remove spaces from object types that contain multiple parts ("posix_sem" -> "posixsem") to make mechanical parsing easier. Introduce a new "netinet" object type for certain IPv4/IPv6-related methods. Also simplify, slightly, some entry point names. All MAC policy modules will need to be recompiled, and modules not updates as part of this commit will need to be modified to conform to the new KPI. Sponsored by: SPARTA (original patches against Mac OS X) Obtained from: TrustedBSD Project, Apple Computer
* Further system call comment cleanup:rwatson2007-03-051-5/+0
| | | | | | | | | | - Remove also "MP SAFE" after prior "MPSAFE" pass. (suggested by bde) - Remove extra blank lines in some cases. - Add extra blank lines in some cases. - Remove no-op comments consisting solely of the function name, the word "syscall", or the system call name. - Add punctuation. - Re-wrap some comments.
* Remove 'MPSAFE' annotations from the comments above most system calls: allrwatson2007-03-041-18/+0
| | | | | | | | system calls now enter without Giant held, and then in some cases, acquire Giant explicitly. Remove a number of other MPSAFE annotations in the credential code and tweak one or two other adjacent comments.
* Remove call to ipcperm() in shmget_existing(). The flags argument isrwatson2007-02-191-3/+0
| | | | | | | | | | | ignored on other systems I investigated when accessing an existing memory segment rather than creating a new one. This call to ipcperm() is the only one to pass in a complete mode flag to the permission checks rather than a simple access request mask, and caused problems for the revised ipcperm() based on the priv(9) interface, which can now be restored. PR: 106078
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hrwatson2006-10-221-1/+2
| | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA
* Remove MAC_DEBUG + MPRINTF debugging from System V IPC. This no longerrwatson2006-09-201-22/+5
| | | | | | | | | appears to be serving a useful purpose, as it was used during initial development of MAC support for System V IPC. MFC after: 1 month Obtained from: TrustedBSD Project Suggested by: Christopher dot Vance at SPARTA dot com
* Move some functions and definitions from uipc_socket2.c to uipc_socket.c:rwatson2006-06-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | - Move sonewconn(), which creates new sockets for incoming connections on listen sockets, so that all socket allocate code is together in uipc_socket.c. - Move 'maxsockets' and associated sysctls to uipc_socket.c with the socket allocation code. - Move kern.ipc sysctl node to uipc_socket.c, add a SYSCTL_DECL() for it to sysctl.h and remove lots of scattered implementations in various IPC modules. - Sort sodealloc() after soalloc() in uipc_socket.c for dependency order reasons. Statisticize soalloc() and sodealloc() as they are now required only in uipc_socket.c, and are internal to the socket implementation. After this change, socket allocation and deallocation is entirely centralized in one file, and uipc_socket2.c consists entirely of socket buffer manipulation and default protocol switch functions. MFC after: 1 month
* Properly support for FreeBSD 4 32bit System V shared memory.ps2006-03-301-0/+10
| | | | | | Submitted by: peter Obtained from: Yahoo! MFC after: 3 weeks
* Re-order MAC and DAC checks in shmget() in order to give precedence torwatson2005-10-041-2/+4
| | | | | | | | the MAC result, as well as avoid losing the DAC check result when MAC is enabled. MFC after: 3 days Reported by: Patrick LeBlanc <Patrick dot LeBlanc at sparta dot com>
* Change the data type of the upper shared memory limits from a signedcsjp2005-08-061-9/+9
| | | | | | | | | | | | integer to an unsigned long. This lifts variables like the maximum number of pages available for shared memory from 2^31 to 2^32 on 32 bit architectures, and from 2^31 to 2^64 on 64 bit architectures. It should be noted that this changes breaks ABI on 64 bit architectures because the size of the shmmax, shmmin, shmmni, shmseg and shmall members of the shminfo structure has changed. Silence on: current@
OpenPOWER on IntegriCloud