1. 08 2月, 2014 1 次提交
    • H
      tty: Set correct tty name in 'active' sysfs attribute · d8a5dc30
      Hannes Reinecke 提交于
      The 'active' sysfs attribute should refer to the currently active tty
      devices the console is running on, not the currently active console.
      
      The console structure doesn't refer to any device in sysfs, only the tty
      the console is running on has.  So we need to print out the tty names in
      'active', not the console names.
      
      This resolves an issue on s390 platforms in determining the correct
      console device to use.
      
      Cc: Lennart Poettering <lennart@poettering.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: David Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NWerner Fink <werner@suse.de>
      Signed-off-by: NHannes Reinecke <hare@suse.de>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8a5dc30
  2. 26 11月, 2013 1 次提交
  3. 18 9月, 2013 1 次提交
  4. 02 8月, 2013 1 次提交
    • P
      tty: Only hangup once · cb50e523
      Peter Hurley 提交于
      Instrumented testing shows a tty can be hungup multiple times [1].
      Although concurrent hangups are properly serialized, multiple
      hangups for the same tty should be prevented.
      
      If tty has already been HUPPED, abort hangup. Note it is not
      necessary to cleanup file *redirect on subsequent hangups,
      as only TIOCCONS can set that value and ioctls are disabled
      after hangup.
      
      [1]
      Test performed by simulating a concurrent async hangup via
      tty_hangup() with a sync hangup via tty_vhangup(), while
      __tty_hangup() was instrumented with:
      
      	diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
      	index 26bb78c..fe8b061 100644
      	--- a/drivers/tty/tty_io.c
      	+++ b/drivers/tty/tty_io.c
      	@@ -629,6 +629,8 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
      
      		tty_lock(tty);
      
      	+	WARN_ON(test_bit(TTY_HUPPED, &tty->flags));
      	+
      		/* some functions below drop BTM, so we need this bit */
      		set_bit(TTY_HUPPING, &tty->flags);
      
      Test result:
      
      WARNING: at /home/peter/src/kernels/mainline/drivers/tty/tty_io.c:632 __tty_hangup+0x459/0x460()
      Modules linked in: ip6table_filter ip6_tables ebtable_nat <...snip...>
      CPU: 6 PID: 1197 Comm: kworker/6:2 Not tainted 3.10.0-0+rfcomm-xeon #0+rfcomm
      Hardware name: Dell Inc. Precision WorkStation T5400  /0RW203, BIOS A11 04/30/2012
      Workqueue: events do_tty_hangup
       0000000000000009 ffff8802b16d7d18 ffffffff816b553e ffff8802b16d7d58
       ffffffff810407e0 ffff880254f95c00 ffff880254f95c00 ffff8802bfd92b00
       ffff8802bfd96b00 ffff880254f95e40 0000000000000180 ffff8802b16d7d68
      Call Trace:
       [<ffffffff816b553e>] dump_stack+0x19/0x1b
       [<ffffffff810407e0>] warn_slowpath_common+0x70/0xa0
       [<ffffffff8104082a>] warn_slowpath_null+0x1a/0x20
       [<ffffffff813fb279>] __tty_hangup+0x459/0x460
       [<ffffffff8107409c>] ? finish_task_switch+0xbc/0xe0
       [<ffffffff813fb297>] do_tty_hangup+0x17/0x20
       [<ffffffff8105fd6f>] process_one_work+0x16f/0x450
       [<ffffffff8106007c>] process_scheduled_works+0x2c/0x40
       [<ffffffff8106060a>] worker_thread+0x26a/0x380
       [<ffffffff810603a0>] ? rescuer_thread+0x310/0x310
       [<ffffffff810698a0>] kthread+0xc0/0xd0
       [<ffffffff816b0000>] ? destroy_compound_page+0x65/0x92
       [<ffffffff810697e0>] ? kthread_create_on_node+0x130/0x130
       [<ffffffff816c495c>] ret_from_fork+0x7c/0xb0
       [<ffffffff810697e0>] ? kthread_create_on_node+0x130/0x130
      ---[ end trace 98d9f01536cf411e ]---
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb50e523
  5. 25 7月, 2013 1 次提交
    • P
      tty: Fix lock order in tty_do_resize() · dee4a0be
      Peter Hurley 提交于
      Commits 6a1c0680 and
      9356b535, respectively
        'tty: Convert termios_mutex to termios_rwsem' and
        'n_tty: Access termios values safely'
      introduced a circular lock dependency with console_lock and
      termios_rwsem.
      
      The lockdep report [1] shows that n_tty_write() will attempt
      to claim console_lock while holding the termios_rwsem, whereas
      tty_do_resize() may already hold the console_lock while
      claiming the termios_rwsem.
      
      Since n_tty_write() and tty_do_resize() do not contend
      over the same data -- the tty->winsize structure -- correct
      the lock dependency by introducing a new lock which
      specifically serializes access to tty->winsize only.
      
      [1] Lockdep report
      
      ======================================================
      [ INFO: possible circular locking dependency detected ]
      3.10.0-0+tip-xeon+lockdep #0+tip Not tainted
      -------------------------------------------------------
      modprobe/277 is trying to acquire lock:
       (&tty->termios_rwsem){++++..}, at: [<ffffffff81452656>] tty_do_resize+0x36/0xe0
      
      but task is already holding lock:
       ((fb_notifier_list).rwsem){.+.+.+}, at: [<ffffffff8107aac6>] __blocking_notifier_call_chain+0x56/0xc0
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #2 ((fb_notifier_list).rwsem){.+.+.+}:
             [<ffffffff810b6d62>] lock_acquire+0x92/0x1f0
             [<ffffffff8175b797>] down_read+0x47/0x5c
             [<ffffffff8107aac6>] __blocking_notifier_call_chain+0x56/0xc0
             [<ffffffff8107ab46>] blocking_notifier_call_chain+0x16/0x20
             [<ffffffff813d7c0b>] fb_notifier_call_chain+0x1b/0x20
             [<ffffffff813d95b2>] register_framebuffer+0x1e2/0x320
             [<ffffffffa01043e1>] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
             [<ffffffffa01bcb05>] nouveau_fbcon_init+0x105/0x140 [nouveau]
             [<ffffffffa01ad0af>] nouveau_drm_load+0x43f/0x610 [nouveau]
             [<ffffffffa008a79e>] drm_get_pci_dev+0x17e/0x2a0 [drm]
             [<ffffffffa01ad4da>] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
             [<ffffffff813b13db>] local_pci_probe+0x4b/0x80
             [<ffffffff813b1701>] pci_device_probe+0x111/0x120
             [<ffffffff814977eb>] driver_probe_device+0x8b/0x3a0
             [<ffffffff81497bab>] __driver_attach+0xab/0xb0
             [<ffffffff814956ad>] bus_for_each_dev+0x5d/0xa0
             [<ffffffff814971fe>] driver_attach+0x1e/0x20
             [<ffffffff81496cc1>] bus_add_driver+0x111/0x290
             [<ffffffff814982b7>] driver_register+0x77/0x170
             [<ffffffff813b0454>] __pci_register_driver+0x64/0x70
             [<ffffffffa008a9da>] drm_pci_init+0x11a/0x130 [drm]
             [<ffffffffa022a04d>] nouveau_drm_init+0x4d/0x1000 [nouveau]
             [<ffffffff810002ea>] do_one_initcall+0xea/0x1a0
             [<ffffffff810c54cb>] load_module+0x123b/0x1bf0
             [<ffffffff810c5f57>] SyS_init_module+0xd7/0x120
             [<ffffffff817677c2>] system_call_fastpath+0x16/0x1b
      
      -> #1 (console_lock){+.+.+.}:
             [<ffffffff810b6d62>] lock_acquire+0x92/0x1f0
             [<ffffffff810430a7>] console_lock+0x77/0x80
             [<ffffffff8146b2a1>] con_flush_chars+0x31/0x50
             [<ffffffff8145780c>] n_tty_write+0x1ec/0x4d0
             [<ffffffff814541b9>] tty_write+0x159/0x2e0
             [<ffffffff814543f5>] redirected_tty_write+0xb5/0xc0
             [<ffffffff811ab9d5>] vfs_write+0xc5/0x1f0
             [<ffffffff811abec5>] SyS_write+0x55/0xa0
             [<ffffffff817677c2>] system_call_fastpath+0x16/0x1b
      
      -> #0 (&tty->termios_rwsem){++++..}:
             [<ffffffff810b65c3>] __lock_acquire+0x1c43/0x1d30
             [<ffffffff810b6d62>] lock_acquire+0x92/0x1f0
             [<ffffffff8175b724>] down_write+0x44/0x70
             [<ffffffff81452656>] tty_do_resize+0x36/0xe0
             [<ffffffff8146c841>] vc_do_resize+0x3e1/0x4c0
             [<ffffffff8146c99f>] vc_resize+0x1f/0x30
             [<ffffffff813e4535>] fbcon_init+0x385/0x5a0
             [<ffffffff8146a4bc>] visual_init+0xbc/0x120
             [<ffffffff8146cd13>] do_bind_con_driver+0x163/0x320
             [<ffffffff8146cfa1>] do_take_over_console+0x61/0x70
             [<ffffffff813e2b93>] do_fbcon_takeover+0x63/0xc0
             [<ffffffff813e67a5>] fbcon_event_notify+0x715/0x820
             [<ffffffff81762f9d>] notifier_call_chain+0x5d/0x110
             [<ffffffff8107aadc>] __blocking_notifier_call_chain+0x6c/0xc0
             [<ffffffff8107ab46>] blocking_notifier_call_chain+0x16/0x20
             [<ffffffff813d7c0b>] fb_notifier_call_chain+0x1b/0x20
             [<ffffffff813d95b2>] register_framebuffer+0x1e2/0x320
             [<ffffffffa01043e1>] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
             [<ffffffffa01bcb05>] nouveau_fbcon_init+0x105/0x140 [nouveau]
             [<ffffffffa01ad0af>] nouveau_drm_load+0x43f/0x610 [nouveau]
             [<ffffffffa008a79e>] drm_get_pci_dev+0x17e/0x2a0 [drm]
             [<ffffffffa01ad4da>] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
             [<ffffffff813b13db>] local_pci_probe+0x4b/0x80
             [<ffffffff813b1701>] pci_device_probe+0x111/0x120
             [<ffffffff814977eb>] driver_probe_device+0x8b/0x3a0
             [<ffffffff81497bab>] __driver_attach+0xab/0xb0
             [<ffffffff814956ad>] bus_for_each_dev+0x5d/0xa0
             [<ffffffff814971fe>] driver_attach+0x1e/0x20
             [<ffffffff81496cc1>] bus_add_driver+0x111/0x290
             [<ffffffff814982b7>] driver_register+0x77/0x170
             [<ffffffff813b0454>] __pci_register_driver+0x64/0x70
             [<ffffffffa008a9da>] drm_pci_init+0x11a/0x130 [drm]
             [<ffffffffa022a04d>] nouveau_drm_init+0x4d/0x1000 [nouveau]
             [<ffffffff810002ea>] do_one_initcall+0xea/0x1a0
             [<ffffffff810c54cb>] load_module+0x123b/0x1bf0
             [<ffffffff810c5f57>] SyS_init_module+0xd7/0x120
             [<ffffffff817677c2>] system_call_fastpath+0x16/0x1b
      
      other info that might help us debug this:
      
      Chain exists of:
        &tty->termios_rwsem --> console_lock --> (fb_notifier_list).rwsem
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock((fb_notifier_list).rwsem);
                                     lock(console_lock);
                                     lock((fb_notifier_list).rwsem);
        lock(&tty->termios_rwsem);
      
       *** DEADLOCK ***
      
      7 locks held by modprobe/277:
       #0:  (&__lockdep_no_validate__){......}, at: [<ffffffff81497b5b>] __driver_attach+0x5b/0xb0
       #1:  (&__lockdep_no_validate__){......}, at: [<ffffffff81497b69>] __driver_attach+0x69/0xb0
       #2:  (drm_global_mutex){+.+.+.}, at: [<ffffffffa008a6dd>] drm_get_pci_dev+0xbd/0x2a0 [drm]
       #3:  (registration_lock){+.+.+.}, at: [<ffffffff813d93f5>] register_framebuffer+0x25/0x320
       #4:  (&fb_info->lock){+.+.+.}, at: [<ffffffff813d8116>] lock_fb_info+0x26/0x60
       #5:  (console_lock){+.+.+.}, at: [<ffffffff813d95a4>] register_framebuffer+0x1d4/0x320
       #6:  ((fb_notifier_list).rwsem){.+.+.+}, at: [<ffffffff8107aac6>] __blocking_notifier_call_chain+0x56/0xc0
      
      stack backtrace:
      CPU: 0 PID: 277 Comm: modprobe Not tainted 3.10.0-0+tip-xeon+lockdep #0+tip
      Hardware name: Dell Inc. Precision WorkStation T5400  /0RW203, BIOS A11 04/30/2012
       ffffffff8213e5e0 ffff8802aa2fb298 ffffffff81755f19 ffff8802aa2fb2e8
       ffffffff8174f506 ffff8802aa2fa000 ffff8802aa2fb378 ffff8802aa2ea8e8
       ffff8802aa2ea910 ffff8802aa2ea8e8 0000000000000006 0000000000000007
      Call Trace:
       [<ffffffff81755f19>] dump_stack+0x19/0x1b
       [<ffffffff8174f506>] print_circular_bug+0x1fb/0x20c
       [<ffffffff810b65c3>] __lock_acquire+0x1c43/0x1d30
       [<ffffffff810b775e>] ? mark_held_locks+0xae/0x120
       [<ffffffff810b78d5>] ? trace_hardirqs_on_caller+0x105/0x1d0
       [<ffffffff810b6d62>] lock_acquire+0x92/0x1f0
       [<ffffffff81452656>] ? tty_do_resize+0x36/0xe0
       [<ffffffff8175b724>] down_write+0x44/0x70
       [<ffffffff81452656>] ? tty_do_resize+0x36/0xe0
       [<ffffffff81452656>] tty_do_resize+0x36/0xe0
       [<ffffffff8146c841>] vc_do_resize+0x3e1/0x4c0
       [<ffffffff8146c99f>] vc_resize+0x1f/0x30
       [<ffffffff813e4535>] fbcon_init+0x385/0x5a0
       [<ffffffff8146a4bc>] visual_init+0xbc/0x120
       [<ffffffff8146cd13>] do_bind_con_driver+0x163/0x320
       [<ffffffff8146cfa1>] do_take_over_console+0x61/0x70
       [<ffffffff813e2b93>] do_fbcon_takeover+0x63/0xc0
       [<ffffffff813e67a5>] fbcon_event_notify+0x715/0x820
       [<ffffffff81762f9d>] notifier_call_chain+0x5d/0x110
       [<ffffffff8107aadc>] __blocking_notifier_call_chain+0x6c/0xc0
       [<ffffffff8107ab46>] blocking_notifier_call_chain+0x16/0x20
       [<ffffffff813d7c0b>] fb_notifier_call_chain+0x1b/0x20
       [<ffffffff813d95b2>] register_framebuffer+0x1e2/0x320
       [<ffffffffa01043e1>] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [<ffffffff8173cbcb>] ? kmemleak_alloc+0x5b/0xc0
       [<ffffffff81198874>] ? kmem_cache_alloc_trace+0x104/0x290
       [<ffffffffa01035e1>] ? drm_fb_helper_single_add_all_connectors+0x81/0xf0 [drm_kms_helper]
       [<ffffffffa01bcb05>] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [<ffffffffa01ad0af>] nouveau_drm_load+0x43f/0x610 [nouveau]
       [<ffffffffa008a79e>] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [<ffffffffa01ad4da>] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [<ffffffff8175f162>] ? _raw_spin_unlock_irqrestore+0x42/0x80
       [<ffffffff813b13db>] local_pci_probe+0x4b/0x80
       [<ffffffff813b1701>] pci_device_probe+0x111/0x120
       [<ffffffff814977eb>] driver_probe_device+0x8b/0x3a0
       [<ffffffff81497bab>] __driver_attach+0xab/0xb0
       [<ffffffff81497b00>] ? driver_probe_device+0x3a0/0x3a0
       [<ffffffff814956ad>] bus_for_each_dev+0x5d/0xa0
       [<ffffffff814971fe>] driver_attach+0x1e/0x20
       [<ffffffff81496cc1>] bus_add_driver+0x111/0x290
       [<ffffffffa022a000>] ? 0xffffffffa0229fff
       [<ffffffff814982b7>] driver_register+0x77/0x170
       [<ffffffffa022a000>] ? 0xffffffffa0229fff
       [<ffffffff813b0454>] __pci_register_driver+0x64/0x70
       [<ffffffffa008a9da>] drm_pci_init+0x11a/0x130 [drm]
       [<ffffffffa022a000>] ? 0xffffffffa0229fff
       [<ffffffffa022a000>] ? 0xffffffffa0229fff
       [<ffffffffa022a04d>] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [<ffffffff810002ea>] do_one_initcall+0xea/0x1a0
       [<ffffffff810c54cb>] load_module+0x123b/0x1bf0
       [<ffffffff81399a50>] ? ddebug_proc_open+0xb0/0xb0
       [<ffffffff813855ae>] ? trace_hardirqs_on_thunk+0x3a/0x3f
       [<ffffffff810c5f57>] SyS_init_module+0xd7/0x120
       [<ffffffff817677c2>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dee4a0be
  6. 24 7月, 2013 5 次提交
  7. 18 6月, 2013 2 次提交
  8. 01 5月, 2013 1 次提交
    • L
      tty: fix up atime/mtime mess, take three · b0b88565
      Linus Torvalds 提交于
      We first tried to avoid updating atime/mtime entirely (commit
      b0de59b5: "TTY: do not update atime/mtime on read/write"), and then
      limited it to only update it occasionally (commit 37b7f3c7: "TTY:
      fix atime/mtime regression"), but it turns out that this was both
      insufficient and overkill.
      
      It was insufficient because we let people attach to the shared ptmx node
      to see activity without even reading atime/mtime, and it was overkill
      because the "only once a minute" means that you can't really tell an
      idle person from an active one with 'w'.
      
      So this tries to fix the problem properly.  It marks the shared ptmx
      node as un-notifiable, and it lowers the "only once a minute" to a few
      seconds instead - still long enough that you can't time individual
      keystrokes, but short enough that you can tell whether somebody is
      active or not.
      Reported-by: NSimon Kirby <sim@hostway.ca>
      Acked-by: NJiri Slaby <jslaby@suse.cz>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b0b88565
  9. 26 4月, 2013 1 次提交
    • J
      TTY: fix atime/mtime regression · 37b7f3c7
      Jiri Slaby 提交于
      In commit b0de59b5 ("TTY: do not update atime/mtime on read/write")
      we removed timestamps from tty inodes to fix a security issue and waited
      if something breaks.  Well, 'w', the utility to find out logged users
      and their inactivity time broke.  It shows that users are inactive since
      the time they logged in.
      
      To revert to the old behaviour while still preventing attackers to
      guess the password length, we update the timestamps in one-minute
      intervals by this patch.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      37b7f3c7
  10. 26 3月, 2013 1 次提交
  11. 19 3月, 2013 5 次提交
  12. 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
  13. 28 2月, 2013 1 次提交
  14. 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
  15. 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
  16. 07 2月, 2013 1 次提交
  17. 16 1月, 2013 1 次提交
  18. 22 11月, 2012 1 次提交
  19. 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
  20. 23 10月, 2012 5 次提交
  21. 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
  22. 07 9月, 2012 1 次提交