1. 19 3月, 2013 1 次提交
  2. 16 3月, 2013 5 次提交
    • P
      tty: Signal SIGHUP before hanging up ldisc · 25fdf243
      Peter Hurley 提交于
      An exiting session leader can hang if a foreground process is
      blocking for line discipline i/o, eg. in n_tty_read(). This happens
      because the blocking reader is holding an ldisc reference (indicating
      the line discipline is in-use) which prevents __tty_hangup() from
      recycling the line discipline. Although waiters are woken before
      attempting to gain exclusive access for changing the ldisc, the
      blocking reader in this case will not exit the i/o loop since it
      has not yet received SIGHUP (because it has not been sent).
      
      Instead, perform signalling first, then recycle the line discipline.
      
      Fixes:
      
      INFO: task init:1 blocked for more than 120 seconds.
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      init            D 00000000001d7180  2688     1      0 0x00000002
       ffff8800b9acfba8 0000000000000002 00000000001d7180 ffff8800b9b10048
       ffff8800b94cb000 ffff8800b9b10000 00000000001d7180 00000000001d7180
       ffff8800b9b10000 ffff8800b9acffd8 00000000001d7180 00000000001d7180
      Call Trace:
       [<ffffffff83db9909>] __schedule+0x2e9/0x3b0
       [<ffffffff83db9b35>] schedule+0x55/0x60
       [<ffffffff83db74ba>] schedule_timeout+0x3a/0x370
       [<ffffffff81182349>] ? mark_held_locks+0xf9/0x130
       [<ffffffff83dbab38>] ? down_failed+0x108/0x200
       [<ffffffff83dbb7ab>] ? _raw_spin_unlock_irq+0x2b/0x80
       [<ffffffff81182608>] ? trace_hardirqs_on_caller+0x128/0x160
       [<ffffffff83dbab61>] down_failed+0x131/0x200
       [<ffffffff83dbbfad>] ? tty_ldisc_lock_pair_timeout+0xcd/0x120
       [<ffffffff83dbae03>] ldsem_down_write+0xd3/0x113
       [<ffffffff83dbbfad>] ? tty_ldisc_lock_pair_timeout+0xcd/0x120
       [<ffffffff8118264d>] ? trace_hardirqs_on+0xd/0x10
       [<ffffffff83dbbfad>] tty_ldisc_lock_pair_timeout+0xcd/0x120
       [<ffffffff81c3df60>] tty_ldisc_hangup+0xd0/0x220
       [<ffffffff81c35bd7>] __tty_hangup+0x137/0x4f0
       [<ffffffff81c37c7c>] disassociate_ctty+0x6c/0x230
       [<ffffffff8111290c>] do_exit+0x41c/0x590
       [<ffffffff8107ad34>] ? syscall_trace_enter+0x24/0x2e0
       [<ffffffff81112b4a>] do_group_exit+0x8a/0xc0
       [<ffffffff81112b92>] sys_exit_group+0x12/0x20
       [<ffffffff83dc49d8>] tracesys+0xe1/0xe6
      1 lock held by init/1:
       #0: (&tty->ldisc_sem){++++++}, at: [<ffffffff83dbbfad>] tty_ldisc_lock_pair_timeout+0xcd/0x120
      Reported-by: NSasha Levin <levinsasha928@gmail.com>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Acked-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25fdf243
    • P
      tty: Signal foreground group processes in hangup · f91e2590
      Peter Hurley 提交于
      When the session leader is exiting, signal the foreground group
      processes as part of the hangup sequence, instead of after the
      hangup is complete. This prepares for hanging up the
      line discipline _after_ signalling processes which
      may be blocking on ldisc i/o.
      
      Parameterize __tty_hangup() to distinguish between when the
      session leader is exiting and all other hangups; signal the
      foreground group after signalling the session leader and its
      process group, which preserves the original signal order.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Acked-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f91e2590
    • P
      tty: Use spin_lock() inside existing critical region · bc30c3b2
      Peter Hurley 提交于
      The interrupt state does not need to be saved, disabled and
      restored here; interrupts are already off because this lock
      is bracketed by spin_lock_irq/spin_unlock_irq.
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Acked-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc30c3b2
    • P
      tty: Fix spinlock flavor in non-atomic __tty_hangup() · 20cc225b
      Peter Hurley 提交于
      __tty_hangup() and tty_vhangup() cannot be called from atomic context,
      so locks do not need to preserve the interrupt state (although,
      still disable interrupts).
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Acked-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      20cc225b
    • P
      tty: Refactor session leader SIGHUP from __tty_hangup() · ea648a47
      Peter Hurley 提交于
      Reduce complexity of __tty_hangup(); separate SIGHUP signalling
      into tty_signal_session_leader().
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Acked-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ea648a47
  3. 28 2月, 2013 1 次提交
  4. 16 2月, 2013 1 次提交
    • J
      TTY: do not update atime/mtime on read/write · b0de59b5
      Jiri Slaby 提交于
      On http://vladz.devzero.fr/013_ptmx-timing.php, we can see how to find
      out length of a password using timestamps of /dev/ptmx. It is
      documented in "Timing Analysis of Keystrokes and Timing Attacks on
      SSH". To avoid that problem, do not update time when reading
      from/writing to a TTY.
      
      I am afraid of regressions as this is a behavior we have since 0.97
      and apps may expect the time to be current, e.g. for monitoring
      whether there was a change on the TTY. Now, there is no change. So
      this would better have a lot of testing before it goes upstream.
      
      References: CVE-2013-0160
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Cc: stable <stable@vger.kernel.org> # after 3.9 is out
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b0de59b5
  5. 14 2月, 2013 1 次提交
    • M
      s390/3270: asynchronous size sensing · 4d334fd1
      Martin Schwidefsky 提交于
      Convert the synchronous size sense code to an interrupt driven
      approach. This allows to set the device online even if the
      terminal is not connected. With the new code views can be
      registered without a connected terminal, the tty can be opened
      as soon as the device is online. After the terminal has been
      connected and the size has been determined the tty is resized
      to match the device characteristics..
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      4d334fd1
  6. 07 2月, 2013 1 次提交
  7. 16 1月, 2013 1 次提交
  8. 22 11月, 2012 1 次提交
  9. 26 10月, 2012 1 次提交
    • C
      tty: Add get- ioctls to fetch tty status v3 · 84fd7bdf
      Cyrill Gorcunov 提交于
      For checkpoint/restore we need to know if tty has
      exclusive or packet mode set, as well as if pty
      is currently locked. Just to be able to restore
      this characteristics.
      
      For this sake the following ioctl codes are introduced
      
       - TIOCGPKT to get packet mode state
       - TIOCGPTLCK to get Pty locked state
       - TIOCGEXCL to get Exclusive mode state
      
      Note this ioctls are a bit unsafe in terms of data
      obtained consistency. The tty characteristics might
      be changed right after ioctl complete. Keep it in
      mind and use this ioctl carefully.
      
      v2:
       - Use TIOC prefix for ioctl codes (by jslaby@)
      Signed-off-by: NCyrill Gorcunov <gorcunov@openvz.org>
      CC: Alan Cox <alan@lxorguk.ukuu.org.uk>
      CC: "H. Peter Anvin" <hpa@zytor.com>
      CC: Pavel Emelyanov <xemul@parallels.com>
      CC: Jiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      84fd7bdf
  10. 23 10月, 2012 5 次提交
  11. 27 9月, 2012 2 次提交
    • A
      make get_file() return its argument · cb0942b8
      Al Viro 提交于
      simplifies a bunch of callers...
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      cb0942b8
    • A
      new helper: iterate_fd() · c3c073f8
      Al Viro 提交于
      iterates through the opened files in given descriptor table,
      calling a supplied function; we stop once non-zero is returned.
      Callback gets struct file *, descriptor number and const void *
      argument passed to iterator.  It is called with files->file_lock
      held, so it is not allowed to block.
      
      tty_io, netprio_cgroup and selinux flush_unauthorized_files()
      converted to its use.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      c3c073f8
  12. 07 9月, 2012 2 次提交
  13. 06 9月, 2012 1 次提交
  14. 17 8月, 2012 1 次提交
  15. 14 8月, 2012 3 次提交
  16. 11 8月, 2012 4 次提交
  17. 28 7月, 2012 1 次提交
    • A
      tty: Fix race in tty release · d155255a
      Alan Cox 提交于
      Ian Abbott found that the tty layer would explode with the right set of
      parallel open and close operations. This is because we race in the
      handling of tty->drivers->termios[].
      
      Correct this by
      	Making tty_ldisc_release behave like nromal code (takes the lock,
      			does stuff, drops the lock)
      	Drop the tty lock earlier in tty_ldisc_release
      	Taking the tty mutex around the driver->termios update in all cases
      	Adding a WARN_ON to catch future screwups.
      
      I also forgot to clean up the pty resources properly. With a pty pair we
      need to pull both halves out of the tables.
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Tested-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d155255a
  18. 18 7月, 2012 1 次提交
  19. 17 7月, 2012 2 次提交
  20. 07 7月, 2012 1 次提交
    • A
      tty: localise the lock · f5e3bcc5
      Alan Cox 提交于
      The termios and other changes mean the other protections needed on the driver
      tty arrays should be adequate. Turn it all back on.
      
      This contains pieces folded in from the fixes made to the original patches
      
      | From: Geert Uytterhoeven <geert@linux-m68k.org>	(fix m68k)
      | From: Paul Gortmaker <paul.gortmaker@windriver.com>	(fix cris)
      | From: Jiri Kosina <jkosina@suze.cz>			(lockdep)
      | From: Eric Dumazet <eric.dumazet@gmail.com>		(lockdep)
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5e3bcc5
  21. 14 6月, 2012 2 次提交
  22. 03 6月, 2012 1 次提交
    • L
      tty: Revert the tty locking series, it needs more work · f309532b
      Linus Torvalds 提交于
      This reverts the tty layer change to use per-tty locking, because it's
      not correct yet, and fixing it will require some more deep surgery.
      
      The main revert is d29f3ef3 ("tty_lock: Localise the lock"), but
      there are several smaller commits that built upon it, they also get
      reverted here. The list of reverted commits is:
      
        fde86d31 - tty: add lockdep annotations
        8f6576ad - tty: fix ldisc lock inversion trace
        d3ca8b64 - pty: Fix lock inversion
        b1d679af - tty: drop the pty lock during hangup
        abcefe5f - tty/amiserial: Add missing argument for tty_unlock()
        fd11b42e - cris: fix missing tty arg in wait_event_interruptible_tty call
        d29f3ef3 - tty_lock: Localise the lock
      
      The revert had a trivial conflict in the 68360serial.c staging driver
      that got removed in the meantime.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f309532b
  23. 05 5月, 2012 1 次提交