summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_pty.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Do not hold onto the fdplock longer then needed. Release the lock afterclaudio2021-02-081-6/+9
| | | | | | | the initial falloc() calls and then regrab it for the fdinsert() or fdremove() calls respectiviely. Also move closef() outside of the lock. This replaces the previously reverted lock order change that was reverted. OK mvs@ visa@
* Revert previous commit. The vnode returned by ptm_vn_open() is open andclaudio2021-02-041-33/+28
| | | | | | | can not simply be vrele()-ed on error. The code currently depends on closef() to do the cleanup. Reported-by: syzbot+b0e18235e96adf81883d@syzkaller.appspotmail.com
* Prevent a lock order issue by shuffling code around. Instead of allocatingclaudio2021-02-041-28/+33
| | | | | | the file descriptors early do it late. This way the fdplock is not held during the VFS operations. OK mvs@
* 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@
* Introduce a helper to check if a signal is ignored or masked by a thread.mpi2020-09-091-3/+2
| | | | ok claudio@, pirofti@
* Sigh. Only the ptyc case should tsleep in ttyretype, since others canderaadt2020-07-201-2/+3
| | | | arrive in the wrong context. Found by jcs.
* A pty write containing VDISCARD, VREPRINT, or various retyping cases ofderaadt2020-07-141-2/+4
| | | | | | | | | 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
* Extend kqueue interface with EVFILT_EXCEPT filter.mpi2020-06-221-1/+22
| | | | | | | | | | This filter, already implemented in macOS and Dragonfly BSD, returns exceptional conditions like the reception of out-of-band data. The functionnality is similar to poll(2)'s POLLPRI & POLLRDBAND and it can be used by the kqfilter-based poll & select implementation. ok millert@ on a previous version, ok visa@
* 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@
* Add missing ICANON check in filt_ptcwrite().mpi2020-05-211-2/+3
| | | | ok millert@, visa@
* 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@
* Convert infinite sleeps to tsleep_nsec(9).mpi2020-01-111-5/+4
| | | | ok bluhm@
* 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-6/+4
| | | | | | | | All callers sleep indefinitely. With help from visa@. ok visa@, ratchov@, kn@
* Bring back revision 1.91 now that vmd has been fixed, repeating theanton2019-03-111-1/+7
| | | | | | | | | | | previous commit message: When closing the slave end of a pty, generate an EOF event to any kqueue consumer of the master end. This behavior is equivalent to how pipes already behave with kqueue. Also, FreeBSD and NetBSD behaves the same way. ok deraadt@ millert@ visa@
* Revert revision 1.91. It results in significant log spam whentb2019-03-061-7/+1
| | | | | | running vmd, as observed by mlarkin and myself. discussed with anton and mlarkin
* When closing the slave end of a pty, generate an EOF event to any kqueueanton2019-03-041-1/+7
| | | | | | | | consumer of the master end. This behavior is equivalent to how pipes already behave with kqueue. Also, FreeBSD and NetBSD behaves the same way. ok deraadt@ millert@
* Remove dead code related to tty allocation for ptys. Back in revision 1.17 ofanton2018-08-301-11/+3
| | | | | | | | | kern/tty_pty.c, allocation of ptys was made dynamic with the introduction of check_pty(). Every time a new struct pty is allocated its corresponding struct tty is also allocated. It's therefore no longer necessary to ensure that a pty has a tty allocated after calling check_pty(). ok deraadt@ millert@ mpi@ visa@
* Initialize device numbers for newly allocated ptys. Prevents a panic caused byanton2018-08-291-5/+9
| | | | | | | | | | the following: a new pty is allocated in which the kernel console output is redirected to, poll(2):ing from /dev/console at this point would be delegated to the device with the major number taken from the pty due to the earlier redirection. Since the pty does not have its correct device major assigned, the wrong device ends up being used. ok deraadt@ millert@
* Decouple unveil from the pledge flags, by adding dedicated unveil flagsbeck2018-08-051-1/+3
| | | | | | | | 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@
* Put file descriptors on shared data structures when they are completelympi2018-06-181-7/+8
| | | | | | | | | | | | | | | | | setup, take 3. LARVAL fd still exist, but they are no longer marked with a flag and no longer reachable via `fd_ofiles[]' or the global linked list. This allows us to simplifies a lot code grabbing new references to fds. All of this is now possible because dup2(2) refuses to clone LARVAL fds. Note that the `fdplock' could now be release in all open(2)-like syscalls, just like it is done in accept(2). With inputs from Mathieu Masson, visa@, guenther@ and art@ Previous version ok bluhm@, ok visa@, sthen@
* Revert introduction of fdinsert(), a sanitify check triggers whenmpi2018-06-051-8/+7
| | | | | | closing a LARVAL file. Found the hardway by sthen@.
* Put file descriptors on shared data structures when they are completelympi2018-06-021-7/+8
| | | | | | | | | | | | | | | | | setup. LARVAL fd still exist, but they are no longer marked with a flag and no longer reachable via `fd_ofiles[]'. This allows us to simplifies a lot code grabbing new references to fds. All of this is now possible because dup2(2) refuses to clone LARVAL fds. Note that the `fdplock' could now be release in all open(2)-like syscalls, just like it is done in accept(2). With inputs from Mathieu -, visa@, guenther@ and art@ ok visa@, bluhm@
* Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysvisa2018-04-281-4/+4
| | | | | | | 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@
* Translate the TIOCSBRK & TIOCCBRK ioctl(2)s issued on a pty(4) slave tompi2018-01-081-1/+15
| | | | | | | | | | | corresponding user mode ioctls. If the master part of the pseudo terminal previously enabled TIOCUCNTL, it will now receive the TIOCUCNTL_{S,C}BRK commands. This allows to send BREAKS commands over a pty(4) independently of the serial terminal emulator used. Guidance and ok nicm@, ok ccardenas@, looks ok to deraadt@
* Stop assuming <sys/file.h> will pull in fcntl.h when _KERNEL is defined.guenther2018-01-021-1/+2
| | | | ok millert@ sthen@
* some of this code was written in an era when spaces cost extra.tedu2017-07-041-15/+15
| | | | add a little breathing room.
* Add a flags argument to falloc() that lets it optionally set theguenther2017-02-111-3/+3
| | | | | | | close-on-exec flag on the newly allocated fd. Make falloc()'s return arguments non-optional: assert that they're not NULL. ok mpi@ millert@
* Remove two sysctls which were introduced only for development of thederaadt2016-05-241-25/+1
| | | | | ptm/pty subsystem, and got left behind. ok beck
* Remove the unused flags argument from VOP_UNLOCK().natano2016-03-191-4/+4
| | | | | | 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-5/+5
|
* Increase buffer sizes and watermarks for tty and pppsf2016-01-141-5/+5
| | | | | | | | | | | | | | | | 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-5/+1
|
* move the pledgenote annotation from `struct proc' to `struct nameidata'semarie2015-11-021-4/+4
| | | | | | | | | | 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@
* There are three situations where pty ioctl's result in a NDINIT.deraadt2015-10-281-1/+5
| | | | | NDINIT should be preceded by setting pledgenote to indicate what the operation is for.
* easy size for free(); ok beckderaadt2015-09-281-2/+2
|
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-5/+5
| | | | | | | - 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@
* Nuke yet more obvious #include duplications.krw2014-11-181-2/+1
| | | | ok miod@
* use mallocarray where arguments are multipled. ok deraadttedu2014-07-131-2/+2
|
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-2/+2
| | | | after discussions with beck deraadt kettenis.
* use explicit_bzero for stack and freed variablestedu2014-07-091-3/+3
|
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-2/+2
| | | | | | | | | 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_sigacts from struct proc to struct process.guenther2014-03-221-2/+2
| | | | testing help mpi@
* Remove the 4.3BSD tty(4) compatibility shims. RIP. ok millert@naddy2013-12-131-14/+1
|
* poll(2) on a closed tty should return POLLIN|POLLHUP in reventsmillert2013-10-111-6/+6
| | | | | | | when events is set to POLLIN and POLLHUP when events is set to POLLOUT. In the pty case we need to be careful to only treat the pty as closed if carrier is on. This fixes a hang on close problem seen with ssh and xterm.
* Back out POLLHUP change until a problem with xterm hanging on closemillert2013-10-061-5/+5
| | | | is fixed.
* poll(2) on a closed tty should return POLLIN|POLLHUP in reventsmillert2013-10-041-5/+5
| | | | | when events is set to POLLIN and POLLHUP when events is set to POLLOUT. OK deraadt@
* Fix a bug in ptcwrite() that could result in up to 100 lost bytesmillert2013-01-021-3/+3
| | | | when we block due to hitting the TTYHOG limit. OK miod@