summaryrefslogtreecommitdiff
path: root/sys/kern/kern_descrip.c
AgeCommit message (Collapse)Author
2016-03-19Remove the unused flags argument from VOP_UNLOCK().natano
torture tested on amd64, i386 and macppc ok beck mpi stefan "the change looks right" deraadt
2016-01-06remove unnecessary casts where the incoming type is void *.Ted Unangst
2015-12-17no need to check null before freeTed Unangst
2015-12-17add size to free. from MathieuTed Unangst
2015-12-05remove stale lint annotationsTed Unangst
2015-11-01refactor pledge_*_check and pledge_fail functionsSebastien Marie
- rename _check function without suffix: a "pledge" function called from anywhere is a "check" function. - makes pledge_fail call the responsability to the _check function. remove it from caller. - make proper use of (potential) returned error of _check() functions. - adds pledge_kill() and pledge_protexec() with and OK deraadt@
2015-10-28Prevent F_SETOWN, unless a "proc" pledge was made.Theo de Raadt
2015-10-21Setting fcntl(F_SETOWN) for a pipe failed with inappropriate ioctlAlexander Bluhm
for device. In sys_fcntl() the ioctl(TIOCSPGRP) is called, but the pipe expects SIOCSPGRP. Sockets have a specal case for the same reason, so adapt the special code for pipes. OK millert@
2015-10-16Implement real "flock" request and add it to userland programs thatTodd C. Miller
use pledge and file locking. OK deraadt@
2015-05-17isatty() is used by stdio to determine the buffering mode. Add a F_ISATTYTheo de Raadt
option to fcntl(), so that isatty() can use this rather than than the bloated ioctl() interface. Reducing uses of ioctl() by libc makes it easier to constrain programs with various kinds of systrace sandboxes. ok guenther, previously discussed as a concept with nicm
2015-04-30Avoid NULL deref in fd_getfile_mode(); OK deraadt@Todd C. Miller
2015-04-30Indroduce fd_getfile_mode() and use it were fd_getfile() is directlyMartin Pieuchot
followed by a mode check. This will simplify the ref/unref dance as soon as fd_getfile() will increment fp's reference counter. Idea from and ok guenther@, ok millert@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-01-19unneccessary cmask variable; ok guentherTheo de Raadt
2014-12-19start retiring the nointr allocator. specify PR_WAITOK as a flag as aTed Unangst
marker for which pools are not interrupt safe. ok dlg
2014-12-16primary change: move uvm_vnode out of vnode, keeping only a pointer.Ted Unangst
objective: vnode.h doesn't include uvm_extern.h anymore. followup changes: include uvm_extern.h or lock.h where necessary. ok and help from deraadt
2014-08-31Add additional kernel interfaces for setting close-on-exec on fdsPhilip Guenther
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC, SOCK_CLOEXEC. Includes SOCK_NONBLOCK support. ok matthew@
2014-07-13use mallocarray where arguments are multipled. ok deraadtTed Unangst
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2014-07-08decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.hTheo de Raadt
don't need to be married. ok guenther miod beck jsing kettenis
2014-06-15Use sizeof(struct file *) consistently for memcpy()'ing fd_ofiles.Matthew Dempsky
Pointed out by Jean-Philippe Ouellet.
2014-05-15Move from struct proc to process the reference-count-holding pointersPhilip Guenther
to the process's vmspace and filedescs. struct proc continues to keep copies of the pointers, copying them on fork, clearing them on exit, and (for vmspace) refreshing on exec. Also, make uvm_swapout_threads() thread aware, eliminating p_swtime in kernel. particular testing by ajacoutot@ and sebastia@
2014-04-12revert falloc change, as it causes all new processes to get stuck after a whileMarc Espie
(race condition ?) problem noticed by me, aja, sthen, brynet, rpe. vanishing after this revert, okay aja@, sthen@ tedu, you probably want to look into re-checking the fcreate/fpublish addition first, then if it's stable, see about tweaking doopenat ?
2014-03-30Eliminates struct pcred by moving the real and saved ugids intoPhilip Guenther
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@
2014-03-08split falloc into two functions, the allocation and the publication.Ted Unangst
the first part is likely to fail, but we can generally prevent the second part from failing. use these two functions to drop the fdp lock around vn_open in sys_open, but still maintain the original semantics of allocate then open. the goal here is to fix the blocked fifo deadlock in a threaded program. testing volunteers in short supply, resorting to conscription
2013-09-14Snapshots for all archs have been built, so remove the T32 codePhilip Guenther
2013-08-13Switch time_t, ino_t, clock_t, and struct kevent's ident and dataPhilip Guenther
members to 64bit types. Assign new syscall numbers for (almost all) the syscalls that involve the affected types, including anything with time_t, timeval, itimerval, timespec, rusage, dirent, stat, or kevent arguments. Add a d_off member to struct dirent and replace getdirentries() with getdents(), thus immensely simplifying and accelerating telldir/seekdir. Build perl with -DBIG_TIME. Bump the major on every single base library: the compat bits included here are only good enough to make the transition; the T32 compat option will be burned as soon as we've reached the new world are are happy with the snapshots for all architectures. DANGER: ABI incompatibility. Updating to this kernel requires extra work or you won't be able to login: install a snapshot instead. Much assistance in fixing userland issues from deraadt@ and tedu@ and build assistance from todd@ and otto@
2013-07-04Format string fixes:Stefan Fritsch
f_count is long ok kettenis@ Change esm_sensor_map.arg to int ok deraadt@
2013-06-11convert some easy bcopy to memcpy and clean up fdexpand a bit.Ted Unangst
ok kettenis
2013-06-05Move FHASLOCK from f_flag to f_iflags, freeing up a bit for passingPhilip Guenther
O_* flags and eliminating an XXX comment. ok matthew@ deraadt@
2012-08-23To protect assumptions inside systrace, don't let systrace fds bePhilip Guenthe
shared between processes. ok djm@
2012-07-11Revert the blocked FIFO open fix, as there's either a race in thePhilip Guenthe
ref-count handling under handling, or blambert@ is messing with my head
2012-07-08Don't hold the fd-table lock across vn_open(), as opening a FIFO may block.Philip Guenthe
Having done that, dupfdopen() has to handle a possible race. ok matthew@ krw@
2012-05-21Cleanup O_CLOEXEC handling and make sure UF_EXCLOSE is set correctlyMatthew Dempsky
when opening /dev/fd/* (i.e., UF_EXCLOSE is now set iff O_CLOEXEC is set, rather than copying UF_EXCLOSE from the file descriptor being dup'd). Also, add support for O_CLOEXEC and O_DIRECTORY to fhopen(). ok krw, guenther; feedback from millert; testing and bug finding by krw
2012-05-14Remove the "vn_open() returning ENXIO means dup+close" hook thatPhilip Guenthe
was used by the now defunct portalfs. Zero out fd_ofileflags[fd] when allocating an fd instead of when releasing it. ok krw@ matthew@
2012-05-01Eliminate the f_usecount ref count in struct file; instead of sleepingPhilip Guenthe
at the top of closef() until all in-progress calls finish, just do the advisory locking bits required of close() by POSIX and let whichever thread has the last reference do the call to the file's fo_close() method and the final cleanup. lots of discussion with deraadt@ and others; worked out with and ok krw@
2012-04-22Add struct proc * argument to FRELE() and FILE_SET_MATURE() inPhilip Guenthe
anticipation of further changes to closef(). No binary change. ok krw@ miod@ deraadt@
2012-04-12In this case where dup2() extends the table using fdalloc, the newlyTheo de Raadt
selected fd is automatically fd_used(). We need to fd_unused() it, because it will be fd_used() again in finishdup(). spotted by guenther ok miod
2012-04-12New system call: getdtablecount(2) returns the number of fileTheo de Raadt
descriptors the process currently has open. ok guenther miod gilles ...
2012-04-12dup() was calling fd_used() twice for the new file descriptor. SeperateTheo de Raadt
the dup and dup2 cases. with guenther ok miod
2012-02-15Hold struct filedesc's fd_lock when writing to the fd_ofiles, fd_ofileflags,Philip Guenthe
or fd_{lo,hi}maps members, or when doing a read for a write. Fixes hangs when an rthreaded processes sleeps while copying the fd table for fork() and catches another thread with the lock. ok jsing@ tedu@
2011-07-08Add F_DUPFD_CLOEXEC.Matthew Dempsky
"Sure" deraadt@
2011-07-08Support sending struct info to kdump. So far for struct stat andOtto Moerbeek
struct sockaddress; mostly from freebsd. ok deraadt@ tedu@ nicm@
2011-04-02Move P_SUGID and P_SUGIDEXEC from struct proc to struct process, soPhilip Guenthe
that you can't evade the checks by doing the dirty work in an rthread ok blambert@, deraadt@
2010-07-26Correct the links between threads, processes, pgrps, and sessions,Philip Guenthe
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
2010-07-19Rollback the allproclk and fileheadlk addition. When grabbing anPhilip Guenthe
rwlock, the thread will release biglock if it sleeps, means that atomicity from before the rw_enter() to after it is not guaranteed. The change didn't address those, so pulling it until it does. "go for it" tedu@
2010-03-24Add a rwlock around the filehead and allproc lists, mainly to protectTed Unangst
list walkers in sysctl that can block. As a reward, no more vslock. With some feedback from art, guenther, phessler. ok guenther.
2009-07-09Remove the VREF() macro and replaces all instances with a call to verf(),Thordur I. Bjornsson
which is exactly what the macro does. Macro's that are nothing more then: #define FUNCTION(arg) function(arg) are almost always pointless and should go away. OK blambert@ Agreed by many.
2008-11-25Punctuate comment for clarity, and keep tense consistent throughoutBret Lambert
ok and improvements jmc@
2008-09-19Fix a bunch of problems and races with posix file locking.Artur Grabowski
- file descriptor table becomes the owner of the lock instead of the proc. - When grabbing the lock, we check if the fd hasn't changed under our feet, this is more or less impossible to solve without a hack like this. I've banged my head against the wall, I figured out a solution, but implementing it correctly would cost me 12 gray hairs. Screw it, this is ugly, but it works. - Wait until usecount drains before releasing the posix lock in closef. - Add missing FREF/FRELE to sys_flock - keep the pid in the flock struct instead of abusing the fact that we used to use the proc as the lock owner. Pointed out by and discussed with Al Viro, big thanks. miod@ ok