summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_prot.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Cache parent's pid as `ps_ppid' and use it instead of `ps_pptr->ps_pid'.mvs2021-01-171-2/+2
| | | | | | This allows us to unlock getppid(2). ok mpi@
* The system calls getgroups(2) and setgroups(2) pass the number ofbluhm2019-07-091-4/+4
| | | | | | | groups as signed int. Do not use unsigned int within the kernel for length calculations. Now getgroups(2) fails with EINVAL if called with negative length value. from Moritz Buhl; OK millert@
* tweak commentvisa2018-06-221-2/+2
|
* Use atomic operations for updating cred structure reference countsvisa2018-06-211-2/+14
| | | | | | | | | | | to make crfree() and crhold() MP-safe. Make crhold() a proper function. Put the definition into file kern_prot.c to constrain the need of the <sys/atomic.h> header. While there, adjust the IPL of ucred_pool to avoid lock order problems with the kernel lock (pointed out by kettenis@). OK mpi@
* Introduce enternewpgrp() & enterthispgrp(), from FreeBSD via guenther@.mpi2018-02-201-11/+21
| | | | | | | This code shuffling will ease the introduction of the proctree lock in sys_setsid() and sys_setpgid(). Extracted from a larger diff from guenther@, ok visa@
* Remove almost unused `flags' argument of suser().mpi2018-02-191-24/+21
| | | | | | | The account flag `ASU' will no longer be set but that makes suser() mpsafe since it no longer mess with a per-process field. No objection from millert@, ok tedu@, bluhm@
* guenther sleep-commited the version without #ifdefsderaadt2017-09-271-1/+3
|
* amd64 needs FS.base values (the TCB pointer) to be validated, as noncanonicalguenther2017-09-271-2/+5
| | | | | | | addresses will cause a fault on load by the kernel. Problem observed by Maxime Villard ok kettenis@ deraadt@
* Delete the getlogin59 syscall, which was last used one year, two releases,guenther2017-04-131-19/+1
| | | | | | and four libc major versions ago ok sthen@ jsing@ deraadt@ jca@
* Provide mips64 with kernel-facing TCB_{GET,SET} macros that store itguenther2017-04-131-5/+2
| | | | | | | in struct mdproc. With that, all archs have those and the __HAVE_MD_TCB macro can be unifdef'ed as always defined. ok kettenis@ visa@ jsing@
* Split PID from TID, giving processes a PID unrelated to the TID of theirguenther2016-11-071-2/+2
| | | | | | initial thread ok jsing@ kettenis@
* add a concept of 'verified auth' to sessions. When set via ioctl,tedu2016-09-021-1/+2
| | | | | | | | the user and parent process are recorded. Later, this info may be tested and used to bypass authorization requirements. ie, doas won't ask for your password again. Great idea from henning. ok deraadt guenther henning
* Add getlogin_r syscall that checks and returns errors like userspaceguenther2016-03-301-3/+26
| | | | | | getlogin_r() API; keep existing syscall as getlogin59 for temporary compat. ok kettenis@ deraadt@
* In setlogin(), don't change anything on error.guenther2016-03-291-4/+6
| | | | ok deraadt@ krw@ zhuk@ jca@ millert@
* Return EINVAL if the creds supplied for NFS export have a cr_ngroups lessguenther2015-03-021-2/+5
| | | | | | than zero or greater than NGROUPS_MAX Fixes panic seen by henning@
* use NGROUPS_MAXderaadt2015-01-171-3/+3
|
* The 2nd arg of setpgid(2) should be pid_t, not int.millert2014-09-171-4/+4
| | | | | No functional change as pid_t is defined as int32_t. OK miod@
* Have each thread keeps its own (counted!) reference to the process's ucredsguenther2014-04-181-114/+281
| | | | | | | | | to avoid possible use-after-free references when swapping ids in threaded processes. "Do I have the right creds?" checks are always made with the threads creds. Inspired by FreeBSD and NetBSD "right time" deraadt@
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-119/+117
| | | | | | | | | struct ucred; struct process then directly links to the ucred Based on a discussion at c2k10 or so before noting that FreeBSD and NetBSD did this too. ok matthew@
* The kernel isn't involved in times(3); <sys/times.h> should never beguenther2014-03-241-2/+1
| | | | included there
* Split the API: struct ucred remains the kernel internal structure whileguenther2014-03-241-1/+15
| | | | | | struct xucred becomes the structure for syscalls (mount(2) and nfssvc(2)). ok deraadt@ beck@
* rthreads are always enabled. remove the sysctl.tedu2013-04-061-3/+1
| | | | ok deraadt guenther kettenis matthew
* Make groupmember() check the effective gid too, so that the checks areguenther2012-10-011-1/+3
| | | | | | consistent when the effective gid isn't also a supplementary group. ok beck@
* move accounting flags to struct process; idea and ok guenthermikeb2012-04-121-2/+2
|
* Make the KERN_NPROCS and KERN_MAXPROC sysctl()s and the RLIMIT_NPROC rlimitguenther2012-04-101-5/+5
| | | | | | | | count processes instead of threads. New sysctl()s KERN_NTHREADS and KERN_MAXTHREAD count and limit threads. The nprocs and maxproc kernel variables are replaced by nprocess, maxprocess, nthreads, and maxthread. ok tedu@ mikeb@
* First steps for making ptrace work with rthreads:guenther2012-02-201-2/+2
| | | | | | | | | | - move the P_TRACED and P_INEXEC flags, and p_oppid, p_ptmask, and p_ptstat member from struct proc to struct process - sort the PT_* requests into those that take a PID vs those that can also take a TID - stub in PT_GET_THREAD_FIRST and PT_GET_THREAD_NEXT ok kettenis@
* "TLS-lite": add kernel support for a per-thread userspace pointer,guenther2011-10-151-1/+29
| | | | | | | | | | | for pointing to the thread-control-block. Support for mapping this to the correct hardware register can be added as it's finished; start with support for amd64, sparc, and sparc64. Includes syscalls for getting and setting it (for a portable __errno implementation) as well as creating a new thread with an initial value for it. discussed with miod@, kettenis@, deraadt@; committing to get the syscalls in with the impending libc bump and do further refinements in tree
* two more syscall functions that should have returned int, not pid_ttedu2011-07-251-3/+3
|
* effectively revert 1.44. we don't need the compat_43 syscall returns ever.tedu2011-07-071-7/+4
| | | | getpid is smp safe again. ok guenther
* Move P_EXEC flag from struct proc to process, so that setpgid() willguenther2011-04-041-2/+2
| | | | | | fail regardless of which rthread calls execve() ok blambert@
* Move P_SUGID and P_SUGIDEXEC from struct proc to struct process, soguenther2011-04-021-9/+9
| | | | | | that you can't evade the checks by doing the dirty work in an rthread ok blambert@, deraadt@
* Correct the links between threads, processes, pgrps, and sessions,guenther2010-07-261-37/+41
| | | | | | | | | so that the process-level stuff is to/from struct process and not struct proc. This fixes a bunch of problem cases in rthreads. Based on earlier work by blambert and myself, but mostly written at c2k10. Tested by many: deraadt, sthen, krw, ray, and in snapshots
* Always identify threads with THREAD_PID_OFFSET, so that there's noguenther2010-07-011-2/+2
| | | | | | way a kill() intended for a thread can result in a separate process getting the signal. ok tedu@ art@
* remove the compat43 ifdef around some code. in effect, it's always beentedu2010-06-291-12/+4
| | | | | in compat mode and there's no harm continuing that way. ok dlg deraadt guenther miod thib
* Eliminate RTHREADS kernel option in favor of a sysctl. The actual statustedu2010-06-291-3/+3
| | | | | (not done) hasn't changed, but now it's less work to test things. ok art deraadt
* <sys/time.b> is for ftime(), which is just in libcompat and not the kernel,guenther2010-06-281-2/+1
| | | | | so stop including it in kernel .c files. "sure" deraadt@
* Make sure the process tree is is loop-free by forbidding ptrace()guenther2010-01-281-2/+2
| | | | | | | | of a direct ancestor, closing a localhost DoS. As an exception, do permit ptrace() of pid 1 and have inferiors() stop climbing if it hits that. ok tedu@ hpux_compat suggestion from miod@
* fix typos in comments, no code changes;schwarze2010-01-141-2/+2
| | | | | from Brad Tilley <brad at 16systems dot com>; ok oga@
* ANSIfyguenther2009-06-021-5/+2
| | | | noted by Jonathan ARMANI, ok blambert@
* Move the functionality of psignal() to a new function ptsignal()guenther2008-12-161-2/+2
| | | | | | | | | | | | | that takes an additional argument "type" that indicates whether the signal is for the process, just a particular thread, or propagated to a thread because it's not caught or blocked. psignal() becomes a wrapper that does the first of those. So that sys_kill() can tell apart signals for the process and signals for the process's original thread, the tid of the original thread is defined as its pid + THREAD_PID_OFFSET. ok tedu@ art@ andreas@ kurt@ "better early than late" deraadt@
* change all callers of enterpgrp() to pre-allocate a pgrp or session ifderaadt2008-11-011-15/+37
| | | | | | it might be needed later -- before calling pfind(), so that enterpgrp() can operate without sleeping ok tedu
* accidental commit ... backoutderaadt2008-10-311-39/+15
|
* kern_sysctl.cderaadt2008-10-311-15/+39
|
* Back-in; problems were apparently elsewhere.guenther2008-10-141-5/+5
| | | | | | | | | Put a reference count in struct process to prevent use-after-free if the main thread reaches the reaper ahead of some other thread in the process. Use the reference count to update the user process count correctly when changin real uid. "please re-commit before something else nasty comes in" deraadt@
* backout; is causing some people difficultyderaadt2008-10-101-5/+5
|
* Use the reference count in struct process to update the proc countguenther2008-10-091-5/+5
| | | | | | | for users by the correct amount when changing real UID on (r)threaded processes. ok art@ tedu@
* use PR_ZERO instead of calling bzero directlythib2008-05-221-3/+2
| | | | | | after pool_get(); ok beck@
* Start moving state that is shared among threads in a process intoart2007-04-031-4/+4
| | | | | | | | | | | a new struct. Instead of doing a huge rename and deal with the fallout for weeks, like other projects that need no mention, we will slowly and carefully move things out of struct proc into a new struct process. - Create struct process and the infrastructure to create and remove them. - Move threads in a process into struct process. deraadt@, tedu@ ok
* Since p_flag is often manipulated in interrupts and without biglockart2007-03-151-8/+8
| | | | | | | | | | | | it's a good idea to use atomic.h operations on it. This mechanic change updates all bit operations on p_flag to atomic_{set,clear}bits_int. Only exception is that P_OWEUPC is set by MI code before calling need_proftick and it's automatically cleared by ADDUPC. There's no reason for MD handling of that flag since everyone handles it the same way. kettenis@ ok
* kernel support for threaded processes (rthreads).tedu2005-12-031-3/+17
| | | | | | | | uses rfork(RFTHREAD) to create threads, which are presently processes that are a little more tightly bound together. several new syscalls added to facilitate a userland thread library. all conditional on RTHREADS, currently disabled. ok deraadt