summaryrefslogtreecommitdiffstats
path: root/sys/kern/sysv_shm.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Convert sysctl_sysvsem to sysctl_int_boundedgnezdo2020-11-191-65/+44
| | | | | | Performed a minor refactoring and removed a few trailing whitespaces. ok anton@
* kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha2020-06-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
* Grab a reference for the shared memory segment before calling uvm_map()anton2020-03-041-3/+14
| | | | | | | | | | as the same function could end up putting the thread to sleep. Allowing another thread to free the shared memory segment, which in turns causes a use-after-free. With help from and ok millert@ visa@ Reported-by: syzbot+0fc1766671a9461de8a5@syzkaller.appspotmail.com
* Kill uvm_deallocate(9) and use uvm_unmap() directly.mpi2019-11-051-4/+4
| | | | ok kettenis@, semarie@, deraadt@
* Fix previous commit: missed a ds_copyin() moved in rev 1.72guenther2019-11-041-2/+2
|
* Merge sys_shmctl() and shmctl1() again, as we no longer have a need forguenther2019-11-031-15/+8
| | | | | | the copyin/copyout compat shims. ok deraadt@ millert@ anton@
* Copy in the user-supplied buffer in shmctl(2) before looking up theanton2019-10-281-4/+7
| | | | | | | | | shared memory segment. Otherwise, if copyin ends up sleeping it allows another thread to remove the same segment leading to a use-after-free. Feedback from kettenis@ and ok guenther@ Reported-by: syzbot+0de42c2e600a6dd3091d@syzkaller.appspotmail.com
* I am retiring my old email address; replace it with my OpenBSD one.millert2019-01-251-2/+2
|
* free(9) sizes for sysv shm.mpi2018-12-121-3/+6
| | | | ok bluhm@, visa@
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
* pool_setipldlg2016-08-301-1/+2
| | | | ok natano@
* easy free sizes; ok mpideraadt2015-10-071-2/+2
|
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* The flags variable in shmat was not actually used. We need UVM_FLAG_*millert2015-01-151-5/+4
| | | | | | flags, not mmap-style flags for UVM_MAPFLAG(). Remove the nonsensical MAP_ANON|MAP_SHARED value and convert MAP_FIXED to UVM_FLAG_FIXED. OK guenther@
* start retiring the nointr allocator. specify PR_WAITOK as a flag as atedu2014-12-191-3/+2
| | | | marker for which pools are not interrupt safe. ok dlg
* Prefer MADV_* over POSIX_MADV_* in kernel for consistency: the latterguenther2014-12-171-2/+2
| | | | | | doesn't have all the values and therefore can't be used everywhere. ok deraadt@ kettenis@
* Use MAP_INHERIT_* for the 'inh' argument to the UMV_MAPFLAG() macro,guenther2014-12-151-2/+2
| | | | | | eliminating the must-be-kept-in-sync UVM_INH_* macros ok deraadt@ tedu@
* convert bcopy to memcpy. ok millerttedu2014-12-101-4/+4
|
* More malloc() -> mallocarray() in the kernel.doug2014-12-091-3/+3
| | | | ok deraadt@ tedu@
* Replace a plethora of historical protection options with justderaadt2014-11-161-4/+4
| | | | | | | PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h. PROT_MASK is introduced as the one true way of extracting those bits. Remove UVM_ADV_* wrapper, using the standard names. ok doug guenther kettenis
* use mallocarray where arguments are multipled. ok deraadttedu2014-07-131-3/+3
|
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-4/+4
| | | | after discussions with beck deraadt kettenis.
* In prep for killing ps_mainproc, use pr->ps_pid instead ofguenther2014-03-181-3/+3
| | | | | | pr->ps_mainproc->p_pid to get the PID. ok matthew@
* New vmmap implementation.ariane2012-03-091-5/+3
| | | | | | | | | | | | no oks (it is really a pain to review properly) extensively tested, I'm confident it'll be stable 'now is the time' from several icb inhabitants Diff provides: - ability to specify different allocators for different regions/maps - a simpler implementation of the current allocator - currently in compatibility mode: it will generate similar addresses as the old allocator
* Allow segments to be used even after they were marked for deletion withrobert2011-10-271-8/+3
| | | | | | | | | | | | the IPC_RMID flag. This is permitted as an extension beyond the standards and this is similar to what other operating systems like linux do. Because compat_linux(8) was emulating this already, remove that code since now this is the default. input from oga@, guenther@, jmc@, deraadt@ ok deraadt@
* Backout vmmap in order to repair virtual address selection algorithmsariane2011-06-061-1/+4
| | | | outside the tree.
* Reimplement uvm/uvm_map.ariane2011-05-241-4/+1
| | | | | | | | | | | | | vmmap is designed to perform address space randomized allocations, without letting fragmentation of the address space go through the roof. Some highlights: - kernel address space randomization - proper implementation of guardpages - roughly 10% system time reduction during kernel build Tested by alot of people on tech@ and developers. Theo's machines are still happy.
* explicitly specify flags to malloc and pool_get instead of relying on 0.tedu2010-07-031-2/+3
| | | | | This is more clear, and as thib pointed out, the default in softraid was wrong. ok thib.
* msgctl(), shmctl(), semctl() all have operations that are supposedguenther2009-06-021-3/+3
| | | | | | | to return pids, not thread ids, so record the former when performing operations. ok blambert
* replace ctob and btoc with ptoa and atop respectivelymartin2007-09-151-7/+7
| | | | help and ok miod@ thib@
* Use M_ZERO in a few more places to shave bytes from the kernel.art2007-09-071-11/+6
| | | | eyeballed and ok dlg@
* adapt from netbsd:sturm2007-05-291-13/+11
| | | | | | | | | | | fold sys_shmat1() back into sys_shmat(), instead add flag for shmget(2) to specify that later shmat(2) for the shared memory segment should succeed even if the segment would be marked removed; use this to implement the Linux-compatible semantics of shmat(2) this fixes current opera with shm ok millert
* Rename structs oipc_perm, omsqid_ds, osemid_ds, oshmid_ds to ipc_perm23,millert2004-07-151-16/+1
| | | | | etc to avoid confusion and for consistency with the *35 ones. Remove *n2o functions that don't belong outside of compat.
* Move the guts of the {sem,msg,shm}ctl system calls into a new functionmillert2004-07-141-11/+18
| | | | | | | which also takes two function pointers for copyin/copyout. For the real syscalls these are just the normal copyin/copyout functions. For the compat routines, these are funtions that convert between the new and old foo_ds structs automagically. OK deraadt@
* First step towards more sane time handling in the kernel -- this changestholo2004-06-211-5/+5
| | | | | | | | things such that code that only need a second-resolution uptime or wall time, and used to get that from time.tv_secs or mono_time.tv_secs now get this from separate time_t globals time_second and time_uptime. ok art@ niklas@ nordin@
* POSIX says the length parameter for semop(2) and shmget(2) should be size_t.millert2004-05-031-3/+4
| | | | | Create new syscalls with the correct parameters and add compat versions for the old ones under COMPAT_35.
* not a pasto. ok millert@tedu2004-04-161-2/+4
|
* Correct a reference counting bug in shmat(2); adapted from FreeBSD.millert2004-02-051-2/+4
| | | | OK deraadt@ tedu@ dhartmei@
* Remove duplicated code (pasto)millert2003-12-221-3/+1
|
* Linux shmat allows lookup of segments that are marked as removed somillert2003-10-121-2/+8
| | | | our Linux compat should too. From marius aamodt eriksen
* sys/types.h is not really needed with sys/param.h; ok mickey@kevlo2003-08-211-2/+1
|
* Sync with share/misc/license.template and add missing DARPA creditmillert2003-06-171-8/+12
| | | | where applicable.
* Use an ISC-tyle license for all my code; it is simpler and more permissive.millert2003-06-031-22/+11
|
* Nuke a whole bunch of commons; ok tedu (still more to come *sigh*)jason2003-05-121-2/+2
|
* There are two related changes.art2003-04-141-3/+2
| | | | | | | | | | | | The first one is an mquery(2) syscall. It's for asking the VM system about where to map things. It will be used by ld.so, read the man page for details. The second change is related and is a centralization of uvm_map hint that all callers of uvm_map calculated. This will allow us to adjust this hint on architectures that have segments for non-exec mappings. deraadt@ drahn@ ok.
* xerxes [/home/src/local/millert/sudo/sudo-1.6.7] % vi /usr/src/local/TiVo/Linux/Don't allow s{e,h}mmni to be set > 0xffff via sysctl since that couldmillert2003-01-071-3/+3
| | | | | cause id collisions (the macros in <sys/ipc.h> limit the index to 0xffff). Prompted by a conversation with weingart@
* Add a "findremoved" arg to shm_find_segment_by_shmid() similar tomillert2003-01-061-8/+8
| | | | | NetBSD and allow shmctl() to operate on shm segments that have been marked for removal like other OSes do.
* Add my copyright notice.millert2002-12-171-1/+27
|
* Make SysV-style shared memory and semaphore limits sysctl'able.millert2002-12-171-179/+264
| | | | | | | | | | | | Instead of allocating a static amount of memory for the data structures via valloc() in allocsys(), allocate things dynamically using pool(9) when possible and malloc(9) when not. The various members of struct seminfo and struct shminfo are in kern.seminfo and kern.shminfo respectively (not all members of kern.seminfo are changable). The data structures used still leave something to be desired but things are not made worse in that respect by this commit.
* Eliminate the use of KERN_SUCCESS outside of uvm/art2002-11-061-6/+4
| | | | | | | | Also uvm_map returns KERN_* codes that are directly mapped to errnos, so we can return them instead of doing some attempt to translation. drahn@ "I see no problem" pval@ "makes sense"