summaryrefslogtreecommitdiffstats
path: root/sys/kern (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove the "vn_open() returning ENXIO means dup+close" hook thatguenther2012-05-142-51/+17
| | | | | | | was used by the now defunct portalfs. Zero out fd_ofileflags[fd] when allocating an fd instead of when releasing it. ok krw@ matthew@
* Only set a process's start time when starting the main thread. There'sguenther2012-05-101-5/+10
| | | | | | | also no need to protect that and the setting of the AFORK accounting flag with the scheduler lock. ok mikeb@
* Change accept(), recvfrom(), recvmsg(), getsockname(), andmatthew2012-05-061-38/+32
| | | | | | | | | getpeername() to return the untruncated address length in *addrlen instead of the number of bytes copied out. This matches POSIX's requirements and allows userland applications to detect when the returned address was truncated. ok guenther
* take a file descriptor table lock after allocating pipe structuresmikeb2012-05-061-9/+8
| | | | and buffers; ok guenther
* Oops, previous change had some unrelated changes that shouldn't have beenguenther2012-05-021-11/+5
| | | | committed; roll them back.
* Eliminate the f_usecount ref count in struct file; instead of sleepingguenther2012-05-012-36/+28
| | | | | | | | | 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@
* Correct the error path in execve when there's a race to single threadguenther2012-05-011-2/+2
| | | | | | the process. noted and ok markus@
* Cleanup unp_bind() a little:matthew2012-04-261-17/+25
| | | | | | | | | | | | | | - Require sun_family to be set to AF_UNIX (also in unp_connect()) - Ensure internal sockaddr_un's always have their length set to sizeof(struct sockaddr_un) regardless of the user specified length, implicitly extending with NUL characters as necessary. - Normalize sun_path to never contain a non-NUL character after a NUL character. Lack of NUL termination on truncated sockaddrs issue pointed out by Michael Kerrisk on the Austin Group mailing list. ok millert
* In sosend() for AF_UNIX control message sending, correctly calculatederaadt2012-04-241-3/+13
| | | | | | | | the size (internalized ones can be larger on some architectures) for fitting into the socket. Avoid getting confused by sb_hiwat as well. This fixes a variety of issues where sendmsg() would fail to deliver a fd set or fail to wait; even leading to file leakage. Worked on this with claudio for about a week...
* Don't leak mbufs when bind() on a PF_UNIX socket fails.matthew2012-04-231-8/+15
| | | | ok deraadt, miod, guenther
* Add struct proc * argument to FRELE() and FILE_SET_MATURE() inguenther2012-04-2210-68/+69
| | | | | | anticipation of further changes to closef(). No binary change. ok krw@ miod@ deraadt@
* Reset t_column to 0 when initializing a tty.matthew2012-04-221-1/+2
| | | | ok deraadt@
* Make it optional for kvm_getprocs() (and related sysctl) to returnpirofti2012-04-171-1/+9
| | | | | | | | | | | | thread information. Add a KERN_PROC_SHOW_THREADS flag that has to be set in order to get the thread info and make it off by default. This creates backwards compatibility for applications that relied on a given size/number of items to be returned. Modify ps(1) and top(1) accordingly. Okay guenther@.
* If single threading is active, drirect the SIGKILL signal we send to orphanedkettenis2012-04-141-2/+11
| | | | | | | traced processes to the active thread, otherwise we will deadlock resulting in an unkillable stopped process. ok guenther@
* Do not just return in case the provided control buffer is too short sinceclaudio2012-04-141-5/+8
| | | | | | that leaks all the file pointers. Instead make sure that the exit path via restart: -> out: does not free the uninitialized pointer. OK deraadt@ guenther@
* Free tmp buffer in case the cluster allocation failed. Found by David Hill.claudio2012-04-141-2/+4
|
* Revert rev 1.58, as it frees an uninitialized pointerguenther2012-04-141-5/+3
| | | | ok deraadt@
* gc unused functionderaadt2012-04-131-8/+1
|
* For now, direct the kill signal sent by PT_KILL to the thread that made uskettenis2012-04-131-1/+4
| | | | | stop, just like we do for PT_CONTINUE/PT_STEP. The current code isn't ready for directing signals to other threads yet.
* Don't convert a mbuf to a cluster and think the data in the mbuf is stillclaudio2012-04-131-3/+9
| | | | | valid after that. Copy the data into a temp buffer and then copy it back into the shiny new cluster. Problem found by deraadt@. Ok deraadt@
* Backout a tiny part of the previous commit. Decrementing ps_singlecount inkettenis2012-04-131-5/+1
| | | | | | exit1() is wrong, since single_thread_check() already decrements it and may call exit1() after that. I can't reproduce the hang that this was supposed to fix anyway.
* oops, wrong version of diff in previousderaadt2012-04-131-3/+5
|
* Do not clamp the file descriptors to the buffer size; that leads toderaadt2012-04-131-2/+2
| | | | | losing them. ok claudio
* First stab at making ptrace(2) usable for debugging multi-threaded programs.kettenis2012-04-135-18/+50
| | | | | | | | | | It implements a full-stop model where all threads are stopped before handing over control to the debugger. Events are reported as before through wait(2); you will have to call ptrace(PT_GET_PROCESS_STATE, ...) to find out which thread hit the event. Since this changes the size of struct ptrace_state, you will have to recompile gdb. ok guenther@
* unneccessary casts to unsigned; ok claudioderaadt2012-04-133-9/+9
|
* In this case where dup2() extends the table using fdalloc, the newlyderaadt2012-04-121-1/+2
| | | | | | 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
* Add per thread accounting, mainly for usage & friends.pirofti2012-04-121-4/+16
| | | | | | | | | | | | | | This expands the already bloated FILL_KPROC macro to take an extra parameter that indicates if the callee is a thread or a process. The userland bits are adjusted accordingly and ps(1) and top(1) now display per thread usage times when -H is used. Also pkill(1) had to be adjusted so that duplicates don't pop up. libkvm does basically the same thing as the kernel bits. Okay guenther@.
* hibernate: fix lock/unlock mismatchariane2012-04-121-2/+2
| | | | | Unlock missed an 'f', which caused it to unlock the in-use pageqs, rather than the free pageqs as it was supposed to.
* If the "main" thread exits it stays around but unlinks itself from thekettenis2012-04-121-2/+4
| | | | | | | | | | threads list. Calling TAILQ_NEXT on them is a bad idea and will panic the kernel. So check the P_WEXIT flag and pretend the thread doesn't exist if it is set. Also make PT_GET_THREAD_FIRST return the first thread on the threads list instead of the "main" thread, such that you can actually keep enumerating the threads in this case. ok guenther@, miod@
* syncderaadt2012-04-122-7/+7
|
* remove rfork(); ok guenther miodderaadt2012-04-122-53/+4
|
* PT_GETXMMREGS and PT_SETXMMREGS can take a TID.kettenis2012-04-121-1/+7
|
* syncderaadt2012-04-122-30/+12
|
* kill lfs system call lines and libc stubsderaadt2012-04-121-14/+5
|
* syncderaadt2012-04-122-6/+6
|
* New system call: getdtablecount(2) returns the number of filederaadt2012-04-122-3/+12
| | | | | descriptors the process currently has open. ok guenther miod gilles ...
* dup() was calling fd_used() twice for the new file descriptor. Seperatederaadt2012-04-121-7/+8
| | | | | the dup and dup2 cases. with guenther ok miod
* move accounting flags to struct process; idea and ok guenthermikeb2012-04-125-11/+12
|
* Move the P_WAITED flag from struct proc to struct process.kettenis2012-04-113-10/+9
| | | | ok guenther@
* In sendmsg() permit at most 10% of maxfiles to be in-flightderaadt2012-04-111-1/+4
| | | | | | during CMSG_DATA SCM_RIGHTS fd transfers. If this is exceeded, return EMFILE. ok claudio guenther gilles
* SLIST_REMOVE_NEXT -> SLIST_REMOVE_AFTER for better consistency andnaddy2012-04-111-2/+2
| | | | | | | compatibility with FreeBSD/NetBSD. Also rename SIMPLEQ_REMOVE_NEXT to SIMPLEQ_REMOVE_AFTER. ok mikeb@ guenther@
* 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.
* Make the KERN_NPROCS and KERN_MAXPROC sysctl()s and the RLIMIT_NPROC rlimitguenther2012-04-106-37/+63
| | | | | | | | 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@
* When converting the timeout to ticks, both round up and add one to accountguenther2012-04-101-4/+2
| | | | | | for the tick that we're already in the middle of. noted and tested by aja; ok kurt@
* POSIX locks should track the process's pid and not the thread's idguenther2012-04-101-2/+2
|
* Tweak FAT detection/usage. Recognize 'bare' FAT media that lackskrw2012-04-071-8/+13
| | | | | | | | | | the 0x55aa signature. Don't try FAT detection if we have found an OpenBSD MBR partition. Don't try to read a disklabel from 'bare' FAT media. There can't be one. Finally, don't allow the writing of a disklabel on 'bare' FAT media. There is no safe spot for it, and splatting it in the middle of the FAT structures has not proved helpful.
* Implement PT_GET_THREAD_FIRS and PT_GET_THREAD_NEXT.kettenis2012-04-061-5/+23
| | | | ok miod@
* ruadd() does the summing of system and user times, so doing so againguenther2012-04-061-5/+1
| | | | | | results in bogus total times, as reported by numerous ports people. ok miod@
* Some whitespace/paren tweaks. Rename the mbr testing variable fromkrw2012-03-311-6/+6
| | | | 'fattest' to 'mbrtest'. No change to .o.
* Expand the panic to show the malloc type and size. Okay deraadt@.pirofti2012-03-301-2/+3
|