Commit Graph

47 Commits

Author SHA1 Message Date
maxv
a8d918182b Memory leak, found by Mootja. By the way, we probably shouldn't be
returning -1 here.
2016-10-31 15:08:45 +00:00
christos
0196f35dd1 GSoC 2016: Charles Cui: add SEM_NSEMS_MAX 2016-06-10 23:24:33 +00:00
dholland
521eaa499b Define SEM_VALUE_MAX in only one place.
Adding a whole extra header file just for this is not the optimal
solution... but stuffing it in with anything else exposes things that
otherwise wouldn't be.

Nothing in userland should use <sys/semaphore.h> directly, and if some
foolish third-party software should decide to do so anyway in spite of
the instructions to the contrary I will ruthlessly break it later when
the big kernel includes cleanup finally happens.

Reported by Kamil Rytarowski, and, as it turns out, also by Klaus
Heinz in 2008.
2016-04-24 19:48:29 +00:00
pgoyette
06e9554d11 Mark kern.posix.semcnt as READONLY - we don't want users changing the
internal value!
2015-11-09 01:55:03 +00:00
pgoyette
7c02a5abd6 Whether or not the semaphore code is loaded as a module or built-in, its
sysctl data belongs with the module code.  Move it from kern/init_sysctl.c
to kern/uipc_sem.c

While here, add a new sysctl variable kern.posix.semcnt (current count of
semaphores) to complement the existing kern.posix.semmax (maximum number
of semaphores).
2015-11-09 01:21:18 +00:00
matt
45b1ec740d Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
2014-09-05 09:20:59 +00:00
matt
a35d1a8c7c Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.
2014-09-05 05:57:21 +00:00
christos
4cec95f0ea Centralize the computation of struct timespec to the int timo.
Make lwp_park take the regular arguments for specifying what kind
of timeout we supply like clock_nanosleep(), namely clockid_t and flags.
2013-03-29 01:08:17 +00:00
christos
610818b251 expose ksem_t for fstat(8), and implement stat for future reference. 2012-11-25 01:05:04 +00:00
elad
0c9d8d15c9 Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

    http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
    http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
    http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
2012-03-13 18:40:26 +00:00
joerg
f36ba6b5ad sem_open and friends should return EINVAL if the semaphore is not valid. 2012-03-09 21:03:46 +00:00
joerg
4acff4c01b Implement sem_timedwait. 2012-03-08 21:59:24 +00:00
rmind
1acca05347 ksem_free: remove wrong assert. 2011-04-17 20:37:43 +00:00
rmind
d8dc3301a0 - Add nsems_total and track the use of all semaphores (not only named ones).
Prevents ksem module from unloading while anonymous semaphore(s) are in use.
- ksem_free: add few asserts.
2011-04-16 20:39:18 +00:00
rmind
af94df9e5d sys__ksem_close: use fd_close(). 2011-04-15 00:01:48 +00:00
rmind
210bb880b2 Minor comment fix. Use fd_close() in sys__ksem_destroy(), it is cleaner. 2011-04-14 00:32:23 +00:00
rmind
d641b7ec3c do_ksem_open: do not leak the file descriptor on error path.
sys__ksem_unlink: fix comment, release one lock ealier.
2011-04-12 20:37:25 +00:00
rmind
8cf6ae2c0c Highly rewrite POSIX semaphore. Use file descriptor subsystem, greatly
simplify reference counting, and fix various bugs which existed before,
e.g. some incorrect locking or sem_unlink() not checking for permissions.
2011-04-11 22:31:42 +00:00
ad
18e73e1ebe Replace semid_t with intptr_t. No function change. This is a libc/kernel
private interface and so the name change should not affect any third
party code.
2008-11-14 15:49:20 +00:00
ad
e1623d0beb Update a couple of comments. 2008-11-14 13:35:25 +00:00
ad
0b7375c9af Allow the POSIX semaphore code to be loaded as a module. 2008-11-12 14:32:34 +00:00
ad
c81717a5e1 Set kern.posix_semaphores are runtime so it can be a module. 2008-10-22 11:17:08 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad
0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
dsl
7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
rmind
6fcda0686a Increase the default limit of SEM_MAX, allow changing of limit
dynamically via sysctl.  Closes PR/36979.
2007-12-06 01:27:21 +00:00
ad
71d19c248a - ksem_proc_dtor: fix a use-after-free
- LOCK_ASSERT -> KASSERT
- Use kmem(9)
2007-06-15 18:27:13 +00:00
ad
b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
elad
1e70d64818 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 16:55:29 +00:00
yamt
1a7bc55dcc remove some __unused from function parameters. 2006-11-01 10:17:58 +00:00
christos
4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
thorpej
04e486d9f8 Add specificdata support to procs and lwps, each providing their own
wrappers around the speicificdata subroutines.  Also:
- Call the new lwpinit() function from main() after calling procinit().
- Move some pool initialization out of kern_proc.c and into files that
  are directly related to the pools in question (kern_lwp.c and kern_ras.c).
- Convert uipc_sem.c to proc_{get,set}specific(), and eliminate the p_ksems
  member from struct proc.
2006-10-08 04:28:44 +00:00
ad
f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
elad
215bd95ba4 integrate kauth. 2006-05-14 21:15:11 +00:00
cube
f6f0eee324 Change the way semid_t values are chosen. Instead of using kernel
addresses, use a uint32_t counter and the machinery to properly use it.
That makes the ksem_* system calls friendly for COMPAT_NETBSD32.

OK'd by thorpej@.
2006-03-05 00:49:19 +00:00
perry
a2cd732268 Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 19:12:23 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
perry
da8abec863 nuke trailing whitespace 2005-02-26 21:34:55 +00:00
lukem
09b3191490 add missing __KERNEL_RCSID() 2003-07-14 14:59:01 +00:00
fvdl
d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr
960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
itojun
f265a4a4da use strlcpy. [fixed off-by-one in subr_prop.c] 2003-05-16 14:25:02 +00:00
matt
13bf20997a Need to include <sys/sa.h> for <sys/syscall.h> 2003-04-23 17:50:51 +00:00
thorpej
b193480908 Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant.  Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
2003-02-01 06:23:35 +00:00
thorpej
0139305811 Major overhaul of this code, fixing locking protocol issues and handling
of semaphores at fork time.
2003-01-24 01:46:27 +00:00
christos
1dbdd7cc6d sys_ksem -> sys__ksem 2003-01-20 20:24:21 +00:00
christos
1df6f4ff40 add support for p1003.1b semaphores. From FreeBSD 2003-01-20 20:02:56 +00:00