summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_ktrace.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Take an explicit write reference when associating a thread with a ktracevisa2020-04-031-1/+4
| | | | | | | | | | | | | | | vnode. This lets other parts of the kernel see the vnode as active for writing. In particular, now quotaon_vnode() properly sets up quotas for ktrace vnodes. This fixes a crash that could happen if quotas were turned on while a process was ktraced. ktrace vnodes are opened for writing and an initial write reference is provided for them by vn_open(9). However, this reference is removed, too early, when sys_ktrace() calls vn_close(9). Crash reported and fix tested by Bryan Stenson OK mpi@
* Check the outcome of ktrstart() and skip tracing if the trace filevisa2020-03-231-5/+7
| | | | | | header could not be written. OK anton@ mpi@
* Stop tracing if vget(9) fails.mpi2020-03-211-9/+16
| | | | | | | | | Make sure to release the last reference of the vnode after all other traced processes have given up on it. CID 1453020 Unchecked return value. Inputs from guenther@, ok visa@
* Fix vn_open to require an op of 0, and 0 or KERNELPATH only as flags.beck2019-10-061-2/+2
| | | | | | | | sweep tree to correct NDIINT op and flags ahead of time. document the requirement. This allows KERNELPATH to be used to bypass unveil for crash dumps with nosuidcoredump=2 or 3 ok visa@ deraadt@ florian@
* Decouple unveil from the pledge flags, by adding dedicated unveil flagsbeck2018-08-051-1/+2
| | | | | | | | to the namei args. This fixes a bug where chmod would be allowed when with only READ. This also allows some further cleanup of some awkward things like PLEDGE_STAT that will follow Lots of assistence from semarie@ - thanks! ok semarie@
* Grab and/or assert for the KERNEL_LOCK() in in ktrace & pledge.mpi2018-06-201-5/+13
| | | | | | This is required to run network syscall mostly without the KERNEL_LOCK(). ok visa@, kettenis@ as part of a larger diff.
* Drop unnecessary `p' parameter from vget(9).visa2018-05-271-2/+2
| | | | OK mpi@
* Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysvisa2018-04-281-2/+2
| | | | | | | curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@
* Remove almost unused `flags' argument of suser().mpi2018-02-191-2/+2
| | | | | | | 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@
* Don't pull in <sys/file.h> just to get fcntl.hguenther2017-12-301-2/+2
| | | | ok deraadt@ krw@
* Delete fktrace(2). The consequences of it were not thought throughguenther2017-11-281-31/+1
| | | | | | sufficiently and at least one horrific security hole was the result. ok deraadt@ beck@
* add a fktrace syscall that takes a file descriptor instead of a name.tedu2017-08-121-28/+80
| | | | | libc and man page parts to come. ok guenther
* Convert most of the manual checks for CPU hogging to sched_pause().mpi2017-02-141-5/+3
| | | | | | | | The distinction between preempt() and yield() stays as it is usueful to know if a thread decided to yield by itself or if the kernel told him to go away. ok tedu@, guenther@
* p_comm is the process's command and isn't per thread, so move it fromguenther2017-01-211-4/+5
| | | | | | struct proc to struct process. ok deraadt@ kettenis@
* Split PID from TID, giving processes a PID unrelated to the TID of theirguenther2016-11-071-2/+2
| | | | | | initial thread ok jsing@ kettenis@
* Remove the unused flags argument from VOP_UNLOCK().natano2016-03-191-2/+2
| | | | | | torture tested on amd64, i386 and macppc ok beck mpi stefan "the change looks right" deraadt
* No more compat emulations, so remove ktrace EMUL records and the baggageguenther2016-03-061-34/+3
| | | | | | for generating and parsing them. ok mpi@ naddy@ millert@ deraadt@
* Change kernel internal pledge variables to 64bit (to prepare for morederaadt2015-12-061-2/+2
| | | | | extensions). This change is exposed in ktrace.out files ok semarie
* remove stale lint annotationstedu2015-12-051-2/+1
|
* ktrace vnodes do not need to be opened with FREAD, as they arederaadt2015-11-111-3/+3
| | | | | only written to. (Will keep an eye out for NFS surprises) ok guenther
* move the pledgenote annotation from `struct proc' to `struct nameidata'semarie2015-11-021-2/+2
| | | | | | | | | | pledgenote is used for annotate the policy for a namei context. So make it tracking the nameidata. It is expected for the caller to explicitly define the policy. It is a kernel bug to not do so. ok deraadt@
* Though sys_ktrace is not yet pledge allowed, prepare by settingderaadt2015-10-281-2/+2
| | | | | p_pledgenote as required. XXX open question to guenther regarding FREAD to vnopen() / vnclose()
* Fold "malloc" into "stdio" and -- recognizing that no program so far hasderaadt2015-10-251-2/+19
| | | | | | | | | | | | | | | used less than "stdio" -- include all the "self" operations. Instead of different defines, use regular PLEDGE_* in the "p_pledgenote" variable (which indicates the operation subtype a system call is performing). Many checks before easier to understand. p_pledgenote can often be passed directly to ktrace, so that kdump says: 15565 test CALL pledge(0xa9a3f804c51,0) 15565 test STRU pledge request="stdio" 15565 test RET pledge 0 15565 test CALL open(0xa9a3f804c57,0x2<O_RDWR>) 15565 test NAMI "/tmp/testfile" 15565 test PLDG open, "wpath", errno 1 Operation not permitted with help from semarie, ok guenther
* Rename tame() to pledge(). This fairly interface has evolved to be morederaadt2015-10-091-2/+2
| | | | | | 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.
* Add ktracing of argv and envp to execve(2), with envp not traced by defaultguenther2015-10-021-1/+37
| | | | ok tedu@ deraadt@
* Rename __sysctl syscall to just sysctl, as the userland wrapper is no longerguenther2015-09-131-2/+2
| | | | | | necessary ok deraadt@ jsing@
* Delete ktracing of context switches: it's unused, and not particularly useful,guenther2015-09-071-16/+1
| | | | | | | and doing VOP_WRITE() from inside tsleep/msleep makes the locking too complicated, making it harder to move forward on MP changes. ok deraadt@ kettenis@
* Move to tame(int flags, char *paths[]) API/ABI.deraadt2015-08-221-13/+14
| | | | | | | | | | | | 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
* Fix free() of uninitialized variable introduced in previous commit.guenther2015-08-011-16/+12
| | | | | | | Eliminate the goto that I tripped on. problem noted by Mark Latimer (mark.latimer (at) gmail.com) ok miod@ millert@
* Make KTR_SYSRET records variables variables sized, leaving out theguenther2015-07-191-70/+85
| | | | | | | | | | | | | retval on error, including a long long retval on successful lseek(), and including a register_t retval for other successes. This fixes lseek reporting on ILP32 archs. While here, reworking internal kern_ktrace.c bits to be able to pass two buffers to ktrwriteraw(), so we can avoid mallocing a buffer in some cases and so that KTR_GENIO logs are split at PAGE_SIZE, not PAGE_SIZE-sizeof(struct ktrgenio) ok miod@
* Explicitely include <uvm/uvm_extern.h> in order to build on variable page sizemiod2014-12-291-1/+3
| | | | architectures.
* primary change: move uvm_vnode out of vnode, keeping only a pointer.tedu2014-12-161-1/+2
| | | | | | 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
* convert bcopy to memcpy. ok millerttedu2014-12-101-3/+3
|
* Now that threads hold their own reference to their ucreds, sys_ktrace()guenther2014-10-261-4/+1
| | | | | | doesn't need to hold an extra reference during the call ok deraadt@ millert@
* KERNEL_ASSERT_LOCKED(9): Assertion for kernel lock (Rev. 3)uebayasi2014-07-131-4/+2
| | | | | | | | | | | | | | | This adds a new assertion macro, KERNEL_ASSERT_LOCKED(), to assert that kernel_lock is held. In the long process of removing kernel_lock, there will be a lot (hundreds or thousands) of use of this; virtually almost all functions in !MP-safe subsystems should have this assertion. Thus this assertion should have a short, good name. Not only that "KERNEL_ASSERT_LOCKED" is consistent with other KERNEL_* and SCHED_ASSERT_LOCKED() macros. Input from dlg@ guenther@ kettenis@. OK dlg@ guenther@
* pass the size to free in some of the obvious casestedu2014-07-131-7/+8
|
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-5/+5
| | | | after discussions with beck deraadt kettenis.
* decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.hderaadt2014-07-081-3/+1
| | | | | don't need to be married. ok guenther miod beck jsing kettenis
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-8/+8
| | | | | | | | | 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@
* Move p_emul and p_sigcode from proc to process.guenther2014-03-261-34/+34
| | | | | | | | | Tweak the handling of ktrace EMUL when changing ktracing: only generate one per process (not one per thread) and pass the correct proc pointer down to the VFS layer. Permit generating of NAMI and CSW records inside ktrace(2) itself. ok deraadt@ millert@
* bzero -> memsettedu2014-01-211-5/+5
|
* Threads can't be zombies, only processes, so change zombproc to zombprocess,guenther2014-01-201-9/+9
| | | | | | | | make it a list of processes, and change P_NOZOMBIE and P_STOPPED from thread flags to process flags. Add allprocess list for the code that just wants to see processes. ok tedu@
* Correct the handling of I/O of >=2^32 bytes and the ktracing there ofguenther2013-09-141-14/+15
| | | | | | 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.
* always implement stub utrace syscall, but keep the body #ifdef KTRACEtedu2013-06-011-17/+1
| | | | ok guenther matthew
* Add utrace(2), a system call allowing for userland to send its own ktracemiod2013-06-011-4/+59
| | | | | | records. From FreeBSD via otto@, with tweaks suggested by guenther@. Commite on behalf of otto@ who is not around, to ride the libc minor bump. Causes a librthread minor bump as well (new syscall).
* Add a start record to the ktrace and use a special magic string "KTR"mikeb2012-04-101-36/+57
| | | | | | | to identify ktrace files. kdump(1) will now refuse to operate on trace data without the start record and as a bonus will print only PID, unless an -H flag is specified to print PID/TID pairs. Initial diff, input from and ok deraadt, guenther.
* Add tracing and dumping of "pointer to struct" syscall arguments forguenther2012-03-191-1/+4
| | | | | | structs timespec, timeval, sigaction, and rlimit. ok otto@ jsing@
* Handle rthreads consistently in ktrace by moving the flags and vnode intoguenther2011-12-141-85/+123
| | | | | | | | struct process; KTRFAC_ACTIVE becomes P_INKTR. Also, save the credentials used to open the file in sys_ktrace() and use them for all writes to the vnode. much feedback and ok jsing@
* fix small (one stack word) kmem->user leak - the syscall code doesdjm2011-11-211-2/+2
| | | | | | | | not zero retval when returning an error, so don't copy it back to a ktracer in this case. dropped by R00T-DUDE in his "Unusual and Hilarious Vulnerabilities" talk at Ruxcon 2011; ok guenther@ miod@
* Revert art@'s moving around of the KERNEL_LOCK()/KERNEL_UNLOCK() calls,guenther2011-07-111-6/+1
| | | | | | as it causes hangs in some ports, including libsigsegv's configure script confirmed by krw@, landry@