summaryrefslogtreecommitdiff
path: root/sys/kern/tty.c
AgeCommit message (Collapse)Author
2022-08-14remove unneeded includes in sys/kernJonathan Gray
ok mpi@ miod@
2022-07-02Remove unused device poll functions.Visa Hankala
Also remove unneeded includes of <sys/poll.h> and <sys/select.h>. Some addenda from jsg@. OK miod@ mpi@
2022-02-15unifdef TIOCHPCL, 4.3BSD compat ioctlJonathan Gray
ok deraadt@ guenther@
2021-12-15Adjust pty and tty event filtersVisa Hankala
* Implement EVFILT_EXCEPT for ttys for HUP condition detection. This filter is used when pollfd.events has no read/write events. * Add HUP condition detection to filt_ptcwrite() and filt_ttywrite() to reflect ptcpoll() and ttpoll(). Only poll(2) and select(2) can utilize the code; kevent(2) should behave as before with EVFILT_WRITE. * Clear EV_EOF and __EV_HUP if the EOF/HUP condition ends. OK mpi@
2021-12-14Cover all state checks and updates with spltty() in filt_ttyread().Visa Hankala
2021-12-02firstc() and nextc() use an int of global static storage. Make thisTheo de Raadt
a pointer to a local variable to allow concurrent use if that ever needs to happen in the future. ok mpi kettenis
2021-10-24use NULL not 0 for pointer values in kernJonathan Gray
ok semarie@
2021-05-19In ttyinfo() check that ps_vmspace isn't NULL before calculating theMark Kettenis
resident set size. This replicates what the sysctl code does and fixes a kernel crash reported by robert@ ok deraadt@
2021-05-16panic does not require a \n at the end. When one is provided, it looks wrong.Theo de Raadt
2021-02-08Revert the convertion of per-process thread into a SMR_TAILQ.Martin Pieuchot
We did not reach a consensus about using SMR to unlock single_thread_set() so there's no point in keeping this change.
2020-12-25Refactor klist insertion and removalVisa Hankala
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@
2020-12-07Convert the per-process thread list into a SMR_TAILQ.Martin Pieuchot
Currently all iterations are done under KERNEL_LOCK() and therefor use the *_LOCKED() variant. From and ok claudio@
2020-09-09Introduce a helper to check if a signal is ignored or masked by a thread.Martin Pieuchot
ok claudio@, pirofti@
2020-07-22pstat -t was showing bogus column data on ttys, in modes whereTheo de Raadt
newline doesn't occur to rewind to column 0. If OPOST is inactive, simply return 0. ok millert
2020-07-20cleanup ttrstrt; no functional change; ok dlgTheo de Raadt
2020-07-20Sigh. Only the ptyc case should tsleep in ttyretype, since others canTheo de Raadt
arrive in the wrong context. Found by jcs.
2020-07-15Scott Cheloha convinces me the newly added tsleep_nsec should be tsleep,Theo de Raadt
to hint we are doing the minimum scheduler sleep (and as side effect, collecting potential signal status)
2020-07-14Use a rwlock to protect the ttylist, rather than having ttymalloc/ttyfreeTheo de Raadt
callers use spltty. ok kettenis
2020-07-14A pty write containing VDISCARD, VREPRINT, or various retyping cases ofTheo de Raadt
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
2020-06-15Set __EV_HUP when the conditions matching poll(2)'s POLLUP are found.Martin Pieuchot
This is only done in poll-compatibility mode, when __EV_POLL is set. ok visa@, millert@
2020-05-29dev/rndvar.h no longer has statistical interfaces (removed during variousTheo de Raadt
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.
2020-05-08Do not wait indefinitely for flushing when closing a tty.Martin Pieuchot
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@
2020-04-07Abstract the head of knote lists. This allows extending the lists,Visa Hankala
for example, with locking assertions. OK mpi@, anton@
2020-02-20Replace field f_isfd with field f_flags in struct filterops to allowVisa Hankala
adding more filter properties without cluttering the struct. OK mpi@, anton@
2020-02-08Replace ttkqflush() with klist_invalidate() to handle knote listVisa Hankala
invalidation in one place. Store struct tty pointer in kn_hook directly to simplify the code. OK mpi@
2020-01-09Convert sleeps of 1sec or more to tsleep_nsec(9).Martin Pieuchot
ok bluhm@
2020-01-08Unify handling of ioctls FIOSETOWN/SIOCSPGRP/TIOCSPGRP andVisa Hankala
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@
2019-12-31Use C99 designated initializers with struct filterops. In addition,Visa Hankala
make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
2019-07-19ttysleep(): drop unused timeout parametercheloha
All callers sleep indefinitely. With help from visa@. ok visa@, ratchov@, kn@
2019-07-09Use timeout_add_msec(9)kn
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
2019-06-01Revert to using the SCHED_LOCK() to protect time accounting.Martin Pieuchot
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@
2019-05-31Use a per-process mutex to protect time accounting instead of SCHED_LOCK().Martin Pieuchot
Note that hardclock(9) still increments p_{u,s,i}ticks without holding a lock. ok visa@, cheloha@
2019-05-13When killing a process, the signal is handled by any thread thatAlexander Bluhm
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@
2018-09-06fix whitespaceJonathan Gray
2018-08-05Decouple unveil from the pledge flags, by adding dedicated unveil flagsBob Beck
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@
2018-06-16base and ports are now clean of TIOCSTI uses. The #define can now be removed.Theo de Raadt
The code was already changed to return EIO, it will now return ENOTTY since the code is deleted. ok sthen
2018-05-02Remove proc from the parameters of vn_lock(). The parameter isVisa Hankala
unnecessary because curproc always does the locking. OK mpi@
2018-04-28replace add_*_randomness with enqueue_randomness()Jasper Lievisse Adriaanse
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@
2018-04-28Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysVisa Hankala
curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@
2018-02-19Remove almost unused `flags' argument of suser().Martin Pieuchot
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@
2018-02-06reduce scope of variable a bit to avoid shadowingTed Unangst
2017-12-30Don't pull in <sys/file.h> just to get fcntl.hPhilip Guenther
ok deraadt@ krw@
2017-06-29Due to risks known for decades, TIOCSTI now performs no action, and simplyTheo de Raadt
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
2017-01-21p_comm is the process's command and isn't per thread, so move it fromPhilip Guenther
struct proc to struct process. ok deraadt@ kettenis@
2016-07-10POSIX specifies that if a processing calling tcsetpgrp() is in theTodd C. Miller
background it shall receive SIGTTOU. Handle TIOCSPGRP like we do the other tty ioctls that change the terminal. OK deraadt@ guenther@
2016-05-17Allow sendsyslog(2) with LOG_CONS even when /dev/console has notAlexander Bluhm
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@
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-28Convert to uiomove. Diff from Martin Natano.Stefan Kempf
2016-01-14Increase buffer sizes and watermarks for tty and pppStefan Fritsch
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@
2015-12-05remove stale lint annotationsTed Unangst