summaryrefslogtreecommitdiff
path: root/sys/kern/sys_generic.c
AgeCommit message (Collapse)Author
2016-07-05remove some casts that aren't necessary.Ted Unangst
2016-06-07ktrace support for pollfd[] arraysTheo de Raadt
ok guenther
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-18move SS_DNS socket check from kern_plegde.c to sys_generic.cSebastien Marie
this check has nothing to do with pledge(2). make it lives in sys_ioctl() call. while here, move the (fp == NULL) check early and remove duplicate check from pledge_ioctl_check(). ok guenther@ deraadt@
2015-10-11pledge_ioctl_check() will do the killing if neccessary; if it returns,Theo de Raadt
that is an errno to pass up to the calling system call instead. test case is "who < /dev/null", via ttyname().
2015-10-09another stray )Theo de Raadt
2015-10-09shortcircuit TIOCGETA to directly return ENOTTY for non-ttys. It couldTheo de Raadt
be called against a non-tty fd, so as to test "is this a tty". Discovered by sthen and rob pierce at the same time.
2015-10-09Rename tame() to pledge(). This fairly interface has evolved to be moreTheo de Raadt
strict than anticipated. It allows a programmer to pledge/promise/covenant that their program will operate within an easily defined subset of the Unix environment, or it pays the price.
2015-09-11Convert _TM_ flags to TAME_ flags, collapsing the entire mappingTheo de Raadt
layer because the strings select the right options. Mechanical conversion. ok guenther
2015-09-11Only include <sys/tame.h> in the .c files that need itPhilip Guenther
ok deraadt@ miod@
2015-08-22Move to tame(int flags, char *paths[]) API/ABI.Theo de Raadt
The pathlist is a whitelist of dirs and files; anything else returns ENOENT. Recommendation is to use a narrowly defined list. Also add TAME_FATTR, which permits explicit change operations against "struct stat" fields. Some other TAME_ flags are refined slightly. Not cranking libc now, since nothing commited in base uses this and the timing is uncomfortable for others. Discussed with many; thanks for a few bug fixes from semarie, doug, guenther. ok guenther
2015-07-28Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),Philip Guenther
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown. ok millert@ deraadt@
2015-07-19tame(2) is a subsystem which restricts programs into a "reduced featureTheo de Raadt
operating model". This is the kernel component; various changes should proceed in-tree for a while before userland programs start using it. ok miod, discussions and help from many
2015-05-10Set POLLHUP even if no valid events were specified as per POSIX.Todd C. Miller
Since we use the poll backend for select(2), care must be taken not to set the fd's bit in writefds in this case. A kernel-only flag, POLLNOHUP, is used by selscan() to tell the poll backend not to return POLLHUP on EOF. This is currently only used by fifo_poll(). The fifofs regress now passes. OK guenther@
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-02-12Remove useless extern definitions of nselcoll and selwait.Todd C. Miller
OK guenther@
2014-12-10convert bcopy to memcpy. ok millertTed Unangst
2014-11-03pass size argument to free()Theo de Raadt
ok doug tedu
2014-10-13use mallocarray to get the array of pollfd structs.David Gwynne
tweaks and ok millert@ deraadt@
2014-07-13trim some castsTed Unangst
2014-07-13use mallocarray where arguments are multipled. ok deraadtTed Unangst
2014-07-12Refactor out dosigsuspend() functionMatthew Dempsky
Discussed with guenther and kettenis
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-08Repair compilability after the recent uvmexp changes, especially forMiod Vallat
not compile-time-known page size platforms.
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-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-01-21bzero -> memsetTed Unangst
2013-09-14Correct the handling of I/O of >=2^32 bytes and the ktracing there ofPhilip Guenther
by using size_t/ssize_t instead of int/u_int to handle I/O lengths in uiomove(), vn_fsizechk(), and ktrgenio(). Eliminate the always-zero 'error' argument to ktrgenio() at the same time.
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-06-01always implement stub utrace syscall, but keep the body #ifdef KTRACETed Unangst
ok guenther matthew
2013-05-19select(-1, ...) should fail with EINVAL.Philip Guenther
ok matthew@
2013-04-29Extend P_SIGSUSPEND handling in userret() to properly restore theMatthew Dempsky
sigmask even if there are no pending signals under the temporary sigmask. Refactor existing select() and poll() system calls to introduce the pselect() and ppoll() system calls. Add rthread wrappers for pselect() and ppoll(). While there, update cancellation point comments to reflect recent fdatasync() addition. Minor bumps for libc and librthread due to new symbols. ok guenther, millert, deraadt, jmc
2012-07-09Print the fd_set used by select in kdump.Claudio Jeker
OK guenther@ and deraadt@
2012-07-09Compare the size of the static fd_mask against the number of bytes neededClaudio Jeker
not against the number bit / number of fds in the select set. ok guenther@
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-03-19Add tracing and dumping of "pointer to struct" syscall arguments forPhilip Guenthe
structs timespec, timeval, sigaction, and rlimit. ok otto@ jsing@
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-11-06Document a non-obvious reason why something can't overflow.Philip Guenthe
Discussed with deraadt@
2010-12-19Since we have an ioctl that uses a struct with an off_t member as itsMark Kettenis
argument, we need to make sure this buffer has 64-bit alignment, even on 32-bit architectures. Fixes the alignment trap triggered by vnconfig(8) on sparc for kernels compiled with gcc4. ok miod@
2010-08-18delete some rogue spaces and tabs. no binary change.Marco Peereboom
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-08Devices which don't have read or write functionality should not returnTheo de Raadt
enodev to poll, because this returns an errno of 19 in revents. Oops. Use seltrue where needed, and use a new selfalse function for those which don't know if the next op will be non-blocking Mostly discussed with guenther and miod
2010-04-11In sys_ioctl(), change the type of stkbuf to u_long to make sure it isMark Kettenis
properly aligned. Otherwise we lose on strict alignment architectures if the compiler happens to give it a smaller alignment. Fixes another gcc4 problem on sparc64. ok miod@
2009-11-09Every selwakeup() should have a matching KNOTE() (even if kqueue isn'tNicholas Marriott
supported it doesn't do any harm), so put the KNOTE() in selwakeup() itself and remove it from any occurences where both are used, except one for kqueue itself and one in sys_pipe.c (where the selwakeup is under a PIPE_SEL flag). Based on a diff from tedu. ok deraadt
2009-06-08must calculate iovlen or ktrace panics the machine; diff from blambertTheo de Raadt
and it is pretty critical so commiting it now. Any more fallout from the code 'simplication'?
2009-06-04Put readv/writev changes back in, as they no longer hang ckuethe's ntpd.Bret Lambert
Special thanks to ckuethe's ntpd for noticing the problem. ok deraadt@
2009-06-03Revert readv/writev changes, as they trigger an apparent file descriptorBret Lambert
deadlock for ckuethe@ "if you have to revert, you have to revert" deraadt@
2009-06-02set needfree to NULL in sys_writev() so stack garbageThordur I. Bjornsson
does not cause us to call free if we never malloced. crash found by & OK marco@