summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Revert the convertion of per-process thread into a SMR_TAILQ.mpi2021-02-081-4/+4
| | | | | We did not reach a consensus about using SMR to unlock single_thread_set() so there's no point in keeping this change.
* Refactor klist insertion and removalvisa2020-12-251-4/+4
| | | | | | | | | | | | Rename klist_{insert,remove}() to klist_{insert,remove}_locked(). These functions assume that the caller has locked the klist. The current state of locking remains intact because the kernel lock is still used with all klists. Add new functions klist_insert() and klist_remove() that lock the klist internally. This allows some code simplification. OK mpi@
* Convert the per-process thread list into a SMR_TAILQ.mpi2020-12-071-4/+4
| | | | | | | Currently all iterations are done under KERNEL_LOCK() and therefor use the *_LOCKED() variant. From and ok claudio@
* Introduce a helper to check if a signal is ignored or masked by a thread.mpi2020-09-091-7/+4
| | | | ok claudio@, pirofti@
* pstat -t was showing bogus column data on ttys, in modes wherederaadt2020-07-221-2/+3
| | | | | | newline doesn't occur to rewind to column 0. If OPOST is inactive, simply return 0. ok millert
* cleanup ttrstrt; no functional change; ok dlgderaadt2020-07-201-7/+4
|
* Sigh. Only the ptyc case should tsleep in ttyretype, since others canderaadt2020-07-201-8/+4
| | | | arrive in the wrong context. Found by jcs.
* Scott Cheloha convinces me the newly added tsleep_nsec should be tsleep,deraadt2020-07-151-2/+2
| | | | | to hint we are doing the minimum scheduler sleep (and as side effect, collecting potential signal status)
* Use a rwlock to protect the ttylist, rather than having ttymalloc/ttyfreederaadt2020-07-141-8/+21
| | | | | callers use spltty. ok kettenis
* A pty write containing VDISCARD, VREPRINT, or various retyping cases ofderaadt2020-07-141-23/+32
| | | | | | | | | VERASE would perform (sometimes irrelevant) compute in the kernel which can be heavy (especially with our insufficient tty subsystem locking). Use tsleep_nsec for 1 tick in such circumstances to yield cpu, and also bring interruptability to ptcwrite() https://syzkaller.appspot.com/bug?extid=462539bc18fef8fc26cc ok kettenis millert, discussions with greg and anton
* Set __EV_HUP when the conditions matching poll(2)'s POLLUP are found.mpi2020-06-151-1/+3
| | | | | | This is only done in poll-compatibility mode, when __EV_POLL is set. ok visa@, millert@
* dev/rndvar.h no longer has statistical interfaces (removed during variousderaadt2020-05-291-2/+1
| | | | | | conversion steps). it only contains kernel prototypes for 4 interfaces, all of which legitimately belong in sys/systm.h, which are already included by all enqueue_randomness() users.
* Do not wait indefinitely for flushing when closing a tty.mpi2020-05-081-6/+24
| | | | | | | | | | | This prevent exiting processes from hanging when a slave pseudo terminal is close(2)d before its master. From NetBSD via anton@. Reported-by: syzbot+2ed25b5c40d11e4c3beb@syzkaller.appspotmail.com ok anton@, kettenis@
* Abstract the head of knote lists. This allows extending the lists,visa2020-04-071-4/+4
| | | | | | for example, with locking assertions. OK mpi@, anton@
* Replace field f_isfd with field f_flags in struct filterops to allowvisa2020-02-201-3/+3
| | | | | | adding more filter properties without cluttering the struct. OK mpi@, anton@
* Replace ttkqflush() with klist_invalidate() to handle knote listvisa2020-02-081-46/+11
| | | | | | | | invalidation in one place. Store struct tty pointer in kn_hook directly to simplify the code. OK mpi@
* Convert sleeps of 1sec or more to tsleep_nsec(9).mpi2020-01-091-2/+3
| | | | ok bluhm@
* Unify handling of ioctls FIOSETOWN/SIOCSPGRP/TIOCSPGRP andvisa2020-01-081-1/+29
| | | | | | | | | | | | FIOGETOWN/SIOCGPGRP/TIOCGPGRP. Do this by determining the meaning of the ID parameter inside the sigio code. Also add cases for FIOSETOWN and FIOGETOWN where there have been TIOCSPGRP and TIOCGPGRP before. These changes allow removing the ID translation from sys_fcntl() and sys_ioctl(). Idea from NetBSD OK mpi@, claudio@
* Use C99 designated initializers with struct filterops. In addition,visa2019-12-311-5/+14
| | | | | | make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
* ttysleep(): drop unused timeout parametercheloha2019-07-191-11/+11
| | | | | | | | All callers sleep indefinitely. With help from visa@. ok visa@, ratchov@, kn@
* Use timeout_add_msec(9)kn2019-07-091-19/+12
| | | | | | | | | | | | | | | | | | | As per termios(4), "VTIME is a timer of 0.1 second granularity", so convert it to milliseconds by reducing by hz and multiplying with 1000. Furthermore, the specification (and our implementation) define members of the c_cc arry to be of type unsigned char, so both the previous as well as the now used arithmetic operations are guaranteed to not overflow. Since the timeout_add(9) API takes an int argument, the previous long type would always be demoted anyway, so change it to int directly. With this and hz gone, remove the obselete comment. While here, use more mnemonic variable names. Feedback and OK mpi
* Revert to using the SCHED_LOCK() to protect time accounting.mpi2019-06-011-3/+1
| | | | | | | | | It currently creates a lock ordering problem because SCHED_LOCK() is taken by hardclock(). That means the "priorities" of a thread should be moved out of the SCHED_LOCK() first in order to make progress. Reported-by: syzbot+8e4863b3dde88eb706dc@syzkaller.appspotmail.com via anton@ as well as by kettenis@
* Use a per-process mutex to protect time accounting instead of SCHED_LOCK().mpi2019-05-311-1/+3
| | | | | | | Note that hardclock(9) still increments p_{u,s,i}ticks without holding a lock. ok visa@, cheloha@
* When killing a process, the signal is handled by any thread thatbluhm2019-05-131-3/+3
| | | | | | | | | | does not block the signal. If all threads block the signal, we delivered it to the main thread. This does not conform to POSIX. If any thread unblocks the signal, it should be delivered immediately to this thread. Mark such signals pending at the process instead of a single thread. Then any thread can handle it later. OK kettenis@ guenther@
* fix whitespacejsg2018-09-061-3/+3
|
* 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@
* base and ports are now clean of TIOCSTI uses. The #define can now be removed.deraadt2018-06-161-4/+1
| | | | | | The code was already changed to return EIO, it will now return ENOTTY since the code is deleted. ok sthen
* Remove proc from the parameters of vn_lock(). The parameter isvisa2018-05-021-2/+2
| | | | | | unnecessary because curproc always does the locking. OK mpi@
* replace add_*_randomness with enqueue_randomness()jasper2018-04-281-2/+2
| | | | | | | | | this gets rid of the source annotation which doesn't really add anything other than adding complexitiy. randomess is generally good enough that the few extra bits that the source type would add are not worth it. ok mikeb@ deraadt@
* 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@
* reduce scope of variable a bit to avoid shadowingtedu2018-02-061-2/+3
|
* Don't pull in <sys/file.h> just to get fcntl.hguenther2017-12-301-2/+2
| | | | ok deraadt@ krw@
* Due to risks known for decades, TIOCSTI now performs no action, and simplyderaadt2017-06-291-7/+2
| | | | | | | | returns EIO. The base system has been cleaned of TIOCSTI uses (collaboration between anton and I), and the ports tree appears mostly clean. A few stragglers may be discovered and cleaned up later... In a month or so, we should see if the #define can be removed entirely. ok anton tedu, support from millert
* p_comm is the process's command and isn't per thread, so move it fromguenther2017-01-211-2/+2
| | | | | | struct proc to struct process. ok deraadt@ kettenis@
* POSIX specifies that if a processing calling tcsetpgrp() is in themillert2016-07-101-3/+1
| | | | | background it shall receive SIGTTOU. Handle TIOCSPGRP like we do the other tty ioctls that change the terminal. OK deraadt@ guenther@
* Allow sendsyslog(2) with LOG_CONS even when /dev/console has notbluhm2016-05-171-4/+1
| | | | | | | been opened during init(8). Only log with cnwrite() if cn_devvp exists, otherwise use cnputc() as fallback. While there move extern declarations to dev/cons.h. input and OK deraadt@
* 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
* Convert to uiomove. Diff from Martin Natano.stefan2016-01-281-2/+2
|
* Increase buffer sizes and watermarks for tty and pppsf2016-01-141-2/+7
| | | | | | | | | | | | | | | | Use 115200 the default speed for buffer sizing in ttymalloc(). A lot of devices call ttymalloc(0) so this affects quite a few of them. Increases the buffer size for 9600 < baud <= 115200 from 1k to 4k. Make ppp use the lo/hi watermarks from the tty layer which are adjusted according to speed + buffer size. The previous fixed values of 100 and 400 were way too small Make pty call ttymalloc() with baud == 1000000, which is the common value used in the tree for "fast". ok deraadt@
* remove stale lint annotationstedu2015-12-051-2/+1
|
* 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@
* TIOCCONS will probably never be permitted, but it is good style to setderaadt2015-10-281-1/+3
| | | | p_pledgenote before NDINIT()
* Modify ttystats_init() to tell us about the buffer size, so that wederaadt2015-08-281-5/+7
| | | | can pass the size to free()
* two simple free() sizesderaadt2015-08-261-3/+3
|
* Fix tty hiwat handling a bitsf2015-07-201-14/+5
| | | | | | | | | | | | | - Introduce new defines TTHIWATMINSPACE, TTMINHIWAT for some magic values that are used in tty.c. - Remove hiwat adjustments in ttwrite(). This fixes this codepath not being interrupt safe. - Change ttysetwater() to keep at least TTHIWATMINSPACE space above the high water mark. This makes it consistent with ttycheckoutq(). Without this change, the hiwat adjustment change above causes deadlocks in pty. ok kspillner@ commit it now deraadt@
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-2/+2
| | | | | | | - rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
* Add dmesg -s support, to view the output of rc(8) system startup messages.mpf2015-01-131-1/+14
| | | | | Help and feedback by Theo and Miod. OK deraadt@, manpage-ok jmc@
* remove lock.h from uvm_extern.h. another holdover from the simpletonlocktedu2014-12-171-1/+2
| | | | | era. fix uvm including c files to include lock.h or atomic.h as necessary. ok deraadt
* primary change: move uvm_vnode out of vnode, keeping only a pointer.tedu2014-12-161-1/+3
| | | | | | 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