Commit Graph

274 Commits

Author SHA1 Message Date
christos
c0e5049c21 Require exact credential match; this way even if we su to the original user
that created the session, we won't match his credentials.
2016-10-01 04:42:54 +00:00
christos
4b39133eee Weaken the test a bit to still allow non-root to use TIOCSTI; we need to have
the same creds as the session leader process for the tty session.
2016-10-01 03:46:00 +00:00
christos
f08a5ec0bf Only allow root to use TIOCSTI. Don't eat the kauth error number.
It is unexpected for an unprivileged process to gain privs by
typing to root's tty:

$ cat installer
#!/bin/sh
whoami
/usr/sbin/sti /dev/tty whoami\\n

$ su unprivileged -c ./installer
unprivileged
$ whoami
root
2016-09-29 21:46:32 +00:00
msaitoh
8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
christos
c4922ba137 Add console-related ioctls. 2015-10-22 17:36:33 +00:00
christos
054ca2c181 add the pty ioctls to pass through. 2015-10-18 15:58:23 +00:00
christos
8c41569f24 handle the hardware layer tty ioctls directly so that we don't need to load
the compat module for normal operations.
2015-10-18 15:14:50 +00:00
gson
42b8d69040 In ttywait_timo(), break out of loop on all errors, not just
EWOULDBLOCK, as ttywait() did prior to 1.265.
2015-08-25 12:55:30 +00:00
pooka
d8e04c9094 to garnish, dust with _KERNEL_OPT 2015-08-24 22:50:32 +00:00
gson
2a8f000c61 When closing a tty, limit the amount of time spent waiting for the
output to drain to five seconds so that exiting processes with
buffered output for a serial port blocked by flow control or a pty
that is not being read do not hang indefinitely.  Should fix PRs
kern/12534 and kern/17171.  This is an updated version of the change
of tty.c 1.263.
2015-08-19 12:02:55 +00:00
gson
873b1ca5ad Revert previous; it broke the lib/libc/ttyio/t_ttyio/ioctl test case. 2015-06-14 16:19:31 +00:00
gson
6b1c582456 When closing a tty, limit the amount of time spent waiting for the
output to drain to five seconds so that exiting processes with
buffered output for a serial port blocked by flow control do not
hang indefinitely.  Should fix PR kern/12534.  OK christos.
2015-06-12 17:28:53 +00:00
matt
31ef76f127 Don't use catch as a varible name. 2014-09-05 05:33:39 +00:00
dholland
39b82eecb9 Use accessor functions for the tty's table of control characters.
(at least from outside the core tty sources)

Move some xon/xoff code from net/ppp_tty.c to kern/tty.c.
2014-05-22 16:31:19 +00:00
dholland
44a93ea590 Define TTY_ALLOW_PRIVATE in tty.c, tty_pty.c, and tty_conf.c.
These modules are the core of the tty code that in the long term needs
access to struct tty. (It may be that in the future this can be cut
back to just tty.c; we'll see. For now I'll settle for keeping drivers
out of struct tty.)
2014-05-22 16:28:06 +00:00
pooka
4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
mlelstv
5d1221e5bf ttioctl always gets a valid lwp reference. Replace attempt to handle a NULL
reference in only one place with a regular assertion.
2014-02-23 07:54:43 +00:00
christos
a67c3c8971 printflike maintenance. 2013-02-09 00:31:21 +00:00
apb
f6297d7676 Add COMPAT_60 versions of the TIOCPTMGET and TIOCPTSNAME ioctls. 2012-10-19 16:55:22 +00:00
mlelstv
2897603d95 Don't call ureadc() with a spinlock held because ureadc() may fault when
writing to userspace.
2012-10-02 23:10:34 +00:00
mlelstv
cfb7ebba73 Provide consistent locking around getc() in ttread(). This is necessary
to prevent crashes in MPSAFE tty drivers like ucom.
2012-09-30 11:49:44 +00:00
christos
0cd88accfc Better (not racy fix) from Paul Goyette. 2012-08-17 16:21:19 +00:00
christos
33b27c368d Use the queue of the tty not garbage from the stack (Paul Goyette) 2012-08-17 16:14:31 +00:00
christos
eb2f61c4df PR/46780: Dennis Ferguson: Take the easy way out and return EBUSY when changing
the queue size if the output queue is not empty. Other solutions seemed too
complex/fragile.
2012-08-12 14:45:44 +00:00
christos
ae15dfb84e PR/41673: Stathis Kamperis: tcsetpgrp returns EINVAL, but should return EPERM. 2012-03-12 18:27:08 +00:00
christos
0c971d48ea extract broken proc_compare. lwp compares against self. 2011-10-21 02:08:09 +00:00
christos
92a9826daf - Introduce a sysctl to control the default tty queue size kern.tty.qsize,
which defaults to 1024 as before.
- Add two ioctls TIOC{G,S}QSIZE to read and adjust the queue size on
  individual ptys.

NB: ttys (and ptys) still silently (or beepingly (IMAXBEL)) drop
    characters if the queue size is exceeded. I.e. you can appear
    to succeed writing to the {p,t}ty, but not all characters will
    have made it if the queue overflows.  CVS:
2011-09-24 00:05:38 +00:00
christos
04f8076084 Change obsolete CBSIZE constant (48), to a power of two constant (64) that
is close enough to match the original assumptions.
2011-09-23 15:29:08 +00:00
yamt
1adcac88c1 stop using lbolt in tty 2011-07-26 13:14:17 +00:00
joerg
3eb244d801 Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
2011-07-17 20:54:30 +00:00
rmind
2626d57668 Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency.  Remove some unnecessary malloc.h inclusions as well.
2011-04-24 16:26:51 +00:00
martin
4dafc2b43a In ttymalloc() explicitly initialize t_dev to NODEV.
In ptcwakeup() do not bother to wake up a client side if it has not been
opened yet.
The old code would spuriously wakeup the client minor(0) [i.e. ttyp0
typically] or crash the kernel if that wasn't open, see PR kern/40688.
(Old names used to match the PR and test case, adjust names for
/dev/ptm[x] resp. /dev/pts/* accordingly)
2011-04-09 06:34:06 +00:00
christos
7be202c26c fix locking and remove duplicate code. 2011-02-02 03:00:44 +00:00
mbalmer
34218c6ae7 Cast arguments to vaddr_t when using PRIxVADDR in the printf format string. 2011-01-23 11:01:08 +00:00
matt
f8b3fec406 Change ^T/SIGINFO to print the PC/CPU# or PC instead of "running"/"runable"
if a port provide LWP_PC.
2011-01-23 07:30:07 +00:00
dholland
8f6ed30d57 Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
2010-11-19 06:44:33 +00:00
pgoyette
23d5409e7e Update the rest of the kernel to conform to the module subsystem's new
locking protocol.
2010-08-21 13:19:39 +00:00
rmind
3c507045e2 Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour.  Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
2010-07-01 02:38:26 +00:00
yamt
ef7d7e9667 update a comment. 2010-06-13 03:34:19 +00:00
pooka
f0c67b0751 Feed dust to a few linkset uses and explicitly call the constructor. 2010-05-26 23:53:21 +00:00
dsl
65dd100015 Check for zero length read here - and return zero.
Most times we've come through spec_read() which has already done the test,
but not always (eg pty with ptsfs mounted).
Without this there is a simple local-user panic in ureadc().
Noted Matthew Mondor on tech-kern.
2009-10-11 17:20:48 +00:00
elad
1f98cab201 Put the tty opening policy back in the subsystem.
Remove include we don't need from the secmodel code.
2009-10-02 23:58:53 +00:00
christos
f1cd8c73cb Don't return EWOULDBLOCK on an O_NONBLOCK tty file descriptor that has vmin > 0
and vtime > 0. It should be allowed to go to sleep for the sleep interval
indicated in vtime. Reported by der Mouse a long while ago, and this is what
other unixes do.
2009-08-01 23:07:05 +00:00
rmind
440e5485e0 - Rearrange pg_delete() and pg_remove() (renamed pg_free), thus
proc_enterpgrp() with proc_leavepgrp() to free process group and/or
  session without proc_lock held.
- Rename SESSHOLD() and SESSRELE() to  to proc_sesshold() and
  proc_sessrele().  The later releases proc_lock now.

Quick OK by <ad>.
2009-04-25 15:06:31 +00:00
drochner
cf45120117 Avoid deadlock in tty code if a terminal emulation responds to
type/status/etc inquiries. (PR kern/37915)
This is clearly a design problem in tty, but we need a cheap fix now.
The problem is that ttyinput() tries to pull a spinlock which
is already held on calls to t_oproc.
The workaround is based on the fact that within wscons code, the
wsdisplay_emulinput() function is only called directly from
wsdisplaystart(). So we can be sure that the tty lock is held,
and use an inofficial entry point in ttc.c which avoids the locking.
These ate certainly more assumptions than needed by the fix
proposed in the PR, but it doesn't affect (and slow down) other
tty drivers.
2009-01-22 20:40:20 +00:00
yamt
cb1e92d5d5 malloc -> kmem_alloc 2009-01-22 14:38:34 +00:00
ad
92ce8c6a3d Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
2008-11-19 18:35:57 +00:00
uebayasi
714c16bc3e ttywrite: g/c an unused variable (cnt). 2008-08-08 07:18:03 +00:00
uebayasi
d1dfd4fec7 Display t_outcv* channels as "ttyout*", not "ttycan*". 2008-07-31 01:46:40 +00:00
ad
5adf7333fd - PPWAIT is need only be locked by proc_lock, so move it to proc::p_lflag.
- Remove a few needless lock acquires from exec/fork/exit.
- Sprinkle branch hints.

No functional change.
2008-06-16 09:51:14 +00:00