1. 09 9月, 2014 1 次提交
    • C
      tty: Fix potential use after free in release_one_tty · b216df53
      Cyrill Gorcunov 提交于
      In case if we're releasing the last tty reference the following
      call sequence is possible
      
      tty_driver_kref_put
        destruct_tty_driver
          kfree(driver);
      
      where @driver is used in next module_put call, which leads to
      
       | [ 285.964007] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
       | [ 285.964007] Workqueue: events release_one_tty
       | [ 285.964007] task: ffff8800cc7ea5f0 ti: ffff8800cb800000 task.ti: ffff8800cb800000
       | [ 285.964007] RIP: 0010:[<ffffffff810aeaf5>] [<ffffffff810aeaf5>] module_put+0x24/0xf4
       | [ 285.964007] RSP: 0018:ffff8800cb801d48 EFLAGS: 00010213
       | [ 285.964007] RAX: ffff8800cb801fd8 RBX: ffff8800ca3429d0 RCX: ffff8800cb1db400
       | [ 285.964007] RDX: 0000000000000000 RSI: ffffffff817349c1 RDI: 0000000000000001
       | [ 285.964007] RBP: ffff8800cb801d60 R08: ffff8800cd632b40 R09: 0000000000000000
       | [ 285.964007] R10: 00000000ffffffff R11: ffff88011f40a000 R12: 6b6b6b6b6b6b6b6b
       | [ 285.964007] R13: ffff8800ca342520 R14: 0000000000000000 R15: ffff88011f5d8200
       | [ 285.964007] FS: 0000000000000000(0000) GS:ffff88011f400000(0000) knlGS:0000000000000000
       | [ 285.964007] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       | [ 285.964007] CR2: 00007faf5229d090 CR3: 0000000001c0b000 CR4: 00000000000006f0
       | [ 285.964007] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       | [ 285.964007] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       | [ 285.964007] Stack:
       | [ 285.964007] ffff8800ca3429d0 ffff8800ca342a30 ffff8800ca342520 ffff8800cb801d88
       | [ 285.964007] ffffffff8146554a ffff8800cc77cc78 ffff8800ca3429d0 ffff88011f5d3800
       | [ 285.964007] ffff8800cb801e08 ffffffff810683c1 ffffffff810682ff 0000000000000046
       | [ 285.964007] Call Trace:
       | [ 285.964007] [<ffffffff8146554a>] release_one_tty+0x54/0xa3
       | [ 285.964007] [<ffffffff810683c1>] process_one_work+0x223/0x404
       | [ 285.964007] [<ffffffff810682ff>] ? process_one_work+0x161/0x404
       | [ 285.964007] [<ffffffff81068971>] worker_thread+0x136/0x205
       | [ 285.964007] [<ffffffff8106883b>] ? rescuer_thread+0x26a/0x26a
       | [ 285.964007] [<ffffffff8106e5bf>] kthread+0xa2/0xaa
       | [ 285.964007] [<ffffffff810a4586>] ? trace_hardirqs_on_caller+0x16/0x1eb
       | [ 285.964007] [<ffffffff8106e51d>] ? __kthread_parkme+0x65/0x65
       | [ 285.964007] [<ffffffff8173f59c>] ret_from_fork+0x7c/0xb0
       | [ 285.964007] [<ffffffff8106e51d>] ? __kthread_parkme+0x65/0x65
       | [ 285.964007] Code: 09 00 5b 41 5c 5d c3 0f 1f 44 00 00 55 48 85 ff 48 89 e5 41 55 41 54 49 89 fc 53 0f 84 d3 00
       | 00 00 bf 01 00 00 00 e8 d0 a1 fc ff <49> 8b 84 24 50 02 00 00 65 48 ff 40 08 4c 8b 6d 08 0f 1f 44 00
      
      so simply keep a local reference to the module owner and
      use it later.
      
      CC: Pavel Emelyanov <xemul@parallels.com>
      CC: Jiri Slaby <jslaby@suse.cz>
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NCyrill Gorcunov <gorcunov@openvz.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b216df53
  2. 12 7月, 2014 1 次提交
  3. 11 7月, 2014 1 次提交
  4. 17 4月, 2014 1 次提交
    • C
      tty: fix memleak in alloc_pid · c70dbb1e
      Chen Tingjie 提交于
      There is memleak in alloc_pid:
      ------------------------------
      unreferenced object 0xd3453a80 (size 64):
        comm "adbd", pid 1730, jiffies 66363 (age 6586.950s)
        hex dump (first 32 bytes):
          01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 40 c2 f6 d5 00 d3 25 c1 59 28 00 00  ....@.....%.Y(..
        backtrace:
          [<c1a6f15c>] kmemleak_alloc+0x3c/0xa0
          [<c1320546>] kmem_cache_alloc+0xc6/0x190
          [<c125d51e>] alloc_pid+0x1e/0x400
          [<c123d344>] copy_process.part.39+0xad4/0x1120
          [<c123da59>] do_fork+0x99/0x330
          [<c123dd58>] sys_fork+0x28/0x30
          [<c1a89a08>] syscall_call+0x7/0xb
          [<ffffffff>] 0xffffffff
      
      the leak is due to unreleased pid->count, which execute in function:
      get_pid()(pid->count++) and put_pid()(pid->count--).
      
      The race condition as following:
      task[dumpsys]               task[adbd]
      in disassociate_ctty()      in tty_signal_session_leader()
      -----------------------     -------------------------
      tty = get_current_tty();
      // tty is not NULL
      ...
      spin_lock_irq(&current->sighand->siglock);
      put_pid(current->signal->tty_old_pgrp);
      current->signal->tty_old_pgrp = NULL;
      spin_unlock_irq(&current->sighand->siglock);
      
                                  spin_lock_irq(&p->sighand->siglock);
                                  ...
                                  p->signal->tty = NULL;
                                  ...
                                  spin_unlock_irq(&p->sighand->siglock);
      
      tty = get_current_tty();
      // tty NULL, goto else branch by accident.
      if (tty) {
          ...
          put_pid(tty_session);
          put_pid(tty_pgrp);
          ...
      } else {
          print msg
      }
      
      in task[dumpsys], in disassociate_ctty(), tty is set NULL by task[adbd],
      tty_signal_session_leader(), then it goto else branch and lack of
      put_pid(), cause memleak.
      
      move spin_unlock(sighand->siglock) after get_current_tty() can avoid
      the race and fix the memleak.
      Signed-off-by: NZhang Jun <jun.zhang@intel.com>
      Signed-off-by: NChen Tingjie <tingjie.chen@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c70dbb1e
  5. 01 3月, 2014 1 次提交
    • H
      tty: Set correct tty name in 'active' sysfs attribute · 723abd87
      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.
      
      There is one special-case, which is tty0. If the console is directed to
      it, we want 'tty0' to show up in the file, so user-space knows that the
      messages get forwarded to the active VT. The ->device() callback would
      resolve tty0, though. Hence, treat it special and don't call into the VT
      layer to resolve it (plymouth is known to depend on it).
      
      Cc: Lennart Poettering <lennart@poettering.net>
      Cc: Kay Sievers <kay@vrfy.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NWerner Fink <werner@suse.de>
      Signed-off-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      723abd87
  6. 23 2月, 2014 1 次提交
  7. 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
  8. 26 11月, 2013 1 次提交
  9. 18 9月, 2013 1 次提交
  10. 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
  11. 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
  12. 24 7月, 2013 5 次提交
  13. 18 6月, 2013 2 次提交
  14. 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
  15. 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
  16. 26 3月, 2013 1 次提交
  17. 19 3月, 2013 5 次提交
  18. 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
  19. 28 2月, 2013 1 次提交
  20. 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
  21. 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
  22. 07 2月, 2013 1 次提交
  23. 16 1月, 2013 1 次提交
  24. 22 11月, 2012 1 次提交
  25. 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
  26. 23 10月, 2012 2 次提交
    • J
      TTY: move tty buffers to tty_port · ecbbfd44
      Jiri Slaby 提交于
      So this is it. The big step why we did all the work over the past
      kernel releases. Now everything is prepared, so nothing protects us
      from doing that big step.
      
                 |  |            \  \ nnnn/^l      |  |
                 |  |             \  /     /       |  |
                 |  '-,.__   =>    \/   ,-`    =>  |  '-,.__
                 | O __.´´)        (  .`           | O __.´´)
                  ~~~   ~~          ``              ~~~   ~~
      The buffers are now in the tty_port structure and we can start
      teaching the buffer helpers (insert char/string, flip etc.) to use
      tty_port instead of tty_struct all around.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecbbfd44
    • J
      TTY: add port -> tty link · 967fab69
      Jiri Slaby 提交于
      For that purpose we have to temporarily introduce a second tty back
      pointer into tty_port. It is because serial layer, and maybe others,
      still do not use tty_port_tty_set/get. So that we cannot set the
      tty_port->tty to NULL at will now.
      
      Yes, the fix would be to convert whole serial layer and all its users
      to tty_port_tty_set/get. However we are in the process of removing the
      need of tty in most of the call sites, so this would lead to a
      duplicated work.
      
      Instead we have now tty_port->itty (internal tty) which will be used
      only in flush_to_ldisc. For that one it is ensured that itty is valid
      wherever the work is run. IOW, the work is synchronously cancelled
      before we set itty to NULL and also before hangup is processed.
      
      After we need only tty_port and not tty_struct in most code, this
      shall be changed to tty_port_tty_set/get and itty removed completely.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      967fab69