<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/tty/pty.c, branch linux-3.13.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>tty: Fix lock order in tty_do_resize()</title>
<updated>2013-07-24T22:12:53+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-07-24T20:43:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=dee4a0be69c0e2996188e0c46478eadc280a8954'/>
<id>dee4a0be69c0e2996188e0c46478eadc280a8954</id>
<content type='text'>
Commits 6a1c0680cf3ba94356ecd58833e1540c93472a57 and
9356b535fcb71db494fc434acceb79f56d15bda2, 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-&gt;winsize structure -- correct
the lock dependency by introducing a new lock which
specifically serializes access to tty-&gt;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:
 (&amp;tty-&gt;termios_rwsem){++++..}, at: [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0

but task is already holding lock:
 ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-&gt; #2 ((fb_notifier_list).rwsem){.+.+.+}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b797&gt;] down_read+0x47/0x5c
       [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #1 (console_lock){+.+.+.}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff810430a7&gt;] console_lock+0x77/0x80
       [&lt;ffffffff8146b2a1&gt;] con_flush_chars+0x31/0x50
       [&lt;ffffffff8145780c&gt;] n_tty_write+0x1ec/0x4d0
       [&lt;ffffffff814541b9&gt;] tty_write+0x159/0x2e0
       [&lt;ffffffff814543f5&gt;] redirected_tty_write+0xb5/0xc0
       [&lt;ffffffff811ab9d5&gt;] vfs_write+0xc5/0x1f0
       [&lt;ffffffff811abec5&gt;] SyS_write+0x55/0xa0
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #0 (&amp;tty-&gt;termios_rwsem){++++..}:
       [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
       [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
       [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
       [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
       [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
       [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
       [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
       [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
       [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
       [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
       [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
       [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

other info that might help us debug this:

Chain exists of:
  &amp;tty-&gt;termios_rwsem --&gt; console_lock --&gt; (fb_notifier_list).rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock((fb_notifier_list).rwsem);
                               lock(console_lock);
                               lock((fb_notifier_list).rwsem);
  lock(&amp;tty-&gt;termios_rwsem);

 *** DEADLOCK ***

7 locks held by modprobe/277:
 #0:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b5b&gt;] __driver_attach+0x5b/0xb0
 #1:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b69&gt;] __driver_attach+0x69/0xb0
 #2:  (drm_global_mutex){+.+.+.}, at: [&lt;ffffffffa008a6dd&gt;] drm_get_pci_dev+0xbd/0x2a0 [drm]
 #3:  (registration_lock){+.+.+.}, at: [&lt;ffffffff813d93f5&gt;] register_framebuffer+0x25/0x320
 #4:  (&amp;fb_info-&gt;lock){+.+.+.}, at: [&lt;ffffffff813d8116&gt;] lock_fb_info+0x26/0x60
 #5:  (console_lock){+.+.+.}, at: [&lt;ffffffff813d95a4&gt;] register_framebuffer+0x1d4/0x320
 #6:  ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __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:
 [&lt;ffffffff81755f19&gt;] dump_stack+0x19/0x1b
 [&lt;ffffffff8174f506&gt;] print_circular_bug+0x1fb/0x20c
 [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
 [&lt;ffffffff810b775e&gt;] ? mark_held_locks+0xae/0x120
 [&lt;ffffffff810b78d5&gt;] ? trace_hardirqs_on_caller+0x105/0x1d0
 [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
 [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
 [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
 [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
 [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
 [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
 [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
 [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
 [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
 [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
 [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
 [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
 [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
 [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
 [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
 [&lt;ffffffff8173cbcb&gt;] ? kmemleak_alloc+0x5b/0xc0
 [&lt;ffffffff81198874&gt;] ? kmem_cache_alloc_trace+0x104/0x290
 [&lt;ffffffffa01035e1&gt;] ? drm_fb_helper_single_add_all_connectors+0x81/0xf0 [drm_kms_helper]
 [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
 [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
 [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
 [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
 [&lt;ffffffff8175f162&gt;] ? _raw_spin_unlock_irqrestore+0x42/0x80
 [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
 [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
 [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
 [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
 [&lt;ffffffff81497b00&gt;] ? driver_probe_device+0x3a0/0x3a0
 [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
 [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
 [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
 [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
 [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
 [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
 [&lt;ffffffff81399a50&gt;] ? ddebug_proc_open+0xb0/0xb0
 [&lt;ffffffff813855ae&gt;] ? trace_hardirqs_on_thunk+0x3a/0x3f
 [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
 [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commits 6a1c0680cf3ba94356ecd58833e1540c93472a57 and
9356b535fcb71db494fc434acceb79f56d15bda2, 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-&gt;winsize structure -- correct
the lock dependency by introducing a new lock which
specifically serializes access to tty-&gt;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:
 (&amp;tty-&gt;termios_rwsem){++++..}, at: [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0

but task is already holding lock:
 ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-&gt; #2 ((fb_notifier_list).rwsem){.+.+.+}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b797&gt;] down_read+0x47/0x5c
       [&lt;ffffffff8107aac6&gt;] __blocking_notifier_call_chain+0x56/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #1 (console_lock){+.+.+.}:
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff810430a7&gt;] console_lock+0x77/0x80
       [&lt;ffffffff8146b2a1&gt;] con_flush_chars+0x31/0x50
       [&lt;ffffffff8145780c&gt;] n_tty_write+0x1ec/0x4d0
       [&lt;ffffffff814541b9&gt;] tty_write+0x159/0x2e0
       [&lt;ffffffff814543f5&gt;] redirected_tty_write+0xb5/0xc0
       [&lt;ffffffff811ab9d5&gt;] vfs_write+0xc5/0x1f0
       [&lt;ffffffff811abec5&gt;] SyS_write+0x55/0xa0
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

-&gt; #0 (&amp;tty-&gt;termios_rwsem){++++..}:
       [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
       [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
       [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
       [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
       [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
       [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
       [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
       [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
       [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
       [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
       [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
       [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
       [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
       [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
       [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
       [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
       [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
       [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
       [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
       [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
       [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
       [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
       [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
       [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
       [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
       [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
       [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
       [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
       [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
       [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
       [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
       [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
       [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
       [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
       [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
       [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
       [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

other info that might help us debug this:

Chain exists of:
  &amp;tty-&gt;termios_rwsem --&gt; console_lock --&gt; (fb_notifier_list).rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock((fb_notifier_list).rwsem);
                               lock(console_lock);
                               lock((fb_notifier_list).rwsem);
  lock(&amp;tty-&gt;termios_rwsem);

 *** DEADLOCK ***

7 locks held by modprobe/277:
 #0:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b5b&gt;] __driver_attach+0x5b/0xb0
 #1:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff81497b69&gt;] __driver_attach+0x69/0xb0
 #2:  (drm_global_mutex){+.+.+.}, at: [&lt;ffffffffa008a6dd&gt;] drm_get_pci_dev+0xbd/0x2a0 [drm]
 #3:  (registration_lock){+.+.+.}, at: [&lt;ffffffff813d93f5&gt;] register_framebuffer+0x25/0x320
 #4:  (&amp;fb_info-&gt;lock){+.+.+.}, at: [&lt;ffffffff813d8116&gt;] lock_fb_info+0x26/0x60
 #5:  (console_lock){+.+.+.}, at: [&lt;ffffffff813d95a4&gt;] register_framebuffer+0x1d4/0x320
 #6:  ((fb_notifier_list).rwsem){.+.+.+}, at: [&lt;ffffffff8107aac6&gt;] __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:
 [&lt;ffffffff81755f19&gt;] dump_stack+0x19/0x1b
 [&lt;ffffffff8174f506&gt;] print_circular_bug+0x1fb/0x20c
 [&lt;ffffffff810b65c3&gt;] __lock_acquire+0x1c43/0x1d30
 [&lt;ffffffff810b775e&gt;] ? mark_held_locks+0xae/0x120
 [&lt;ffffffff810b78d5&gt;] ? trace_hardirqs_on_caller+0x105/0x1d0
 [&lt;ffffffff810b6d62&gt;] lock_acquire+0x92/0x1f0
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff8175b724&gt;] down_write+0x44/0x70
 [&lt;ffffffff81452656&gt;] ? tty_do_resize+0x36/0xe0
 [&lt;ffffffff81452656&gt;] tty_do_resize+0x36/0xe0
 [&lt;ffffffff8146c841&gt;] vc_do_resize+0x3e1/0x4c0
 [&lt;ffffffff8146c99f&gt;] vc_resize+0x1f/0x30
 [&lt;ffffffff813e4535&gt;] fbcon_init+0x385/0x5a0
 [&lt;ffffffff8146a4bc&gt;] visual_init+0xbc/0x120
 [&lt;ffffffff8146cd13&gt;] do_bind_con_driver+0x163/0x320
 [&lt;ffffffff8146cfa1&gt;] do_take_over_console+0x61/0x70
 [&lt;ffffffff813e2b93&gt;] do_fbcon_takeover+0x63/0xc0
 [&lt;ffffffff813e67a5&gt;] fbcon_event_notify+0x715/0x820
 [&lt;ffffffff81762f9d&gt;] notifier_call_chain+0x5d/0x110
 [&lt;ffffffff8107aadc&gt;] __blocking_notifier_call_chain+0x6c/0xc0
 [&lt;ffffffff8107ab46&gt;] blocking_notifier_call_chain+0x16/0x20
 [&lt;ffffffff813d7c0b&gt;] fb_notifier_call_chain+0x1b/0x20
 [&lt;ffffffff813d95b2&gt;] register_framebuffer+0x1e2/0x320
 [&lt;ffffffffa01043e1&gt;] drm_fb_helper_initial_config+0x371/0x540 [drm_kms_helper]
 [&lt;ffffffff8173cbcb&gt;] ? kmemleak_alloc+0x5b/0xc0
 [&lt;ffffffff81198874&gt;] ? kmem_cache_alloc_trace+0x104/0x290
 [&lt;ffffffffa01035e1&gt;] ? drm_fb_helper_single_add_all_connectors+0x81/0xf0 [drm_kms_helper]
 [&lt;ffffffffa01bcb05&gt;] nouveau_fbcon_init+0x105/0x140 [nouveau]
 [&lt;ffffffffa01ad0af&gt;] nouveau_drm_load+0x43f/0x610 [nouveau]
 [&lt;ffffffffa008a79e&gt;] drm_get_pci_dev+0x17e/0x2a0 [drm]
 [&lt;ffffffffa01ad4da&gt;] nouveau_drm_probe+0x25a/0x2a0 [nouveau]
 [&lt;ffffffff8175f162&gt;] ? _raw_spin_unlock_irqrestore+0x42/0x80
 [&lt;ffffffff813b13db&gt;] local_pci_probe+0x4b/0x80
 [&lt;ffffffff813b1701&gt;] pci_device_probe+0x111/0x120
 [&lt;ffffffff814977eb&gt;] driver_probe_device+0x8b/0x3a0
 [&lt;ffffffff81497bab&gt;] __driver_attach+0xab/0xb0
 [&lt;ffffffff81497b00&gt;] ? driver_probe_device+0x3a0/0x3a0
 [&lt;ffffffff814956ad&gt;] bus_for_each_dev+0x5d/0xa0
 [&lt;ffffffff814971fe&gt;] driver_attach+0x1e/0x20
 [&lt;ffffffff81496cc1&gt;] bus_add_driver+0x111/0x290
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff814982b7&gt;] driver_register+0x77/0x170
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffff813b0454&gt;] __pci_register_driver+0x64/0x70
 [&lt;ffffffffa008a9da&gt;] drm_pci_init+0x11a/0x130 [drm]
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a000&gt;] ? 0xffffffffa0229fff
 [&lt;ffffffffa022a04d&gt;] nouveau_drm_init+0x4d/0x1000 [nouveau]
 [&lt;ffffffff810002ea&gt;] do_one_initcall+0xea/0x1a0
 [&lt;ffffffff810c54cb&gt;] load_module+0x123b/0x1bf0
 [&lt;ffffffff81399a50&gt;] ? ddebug_proc_open+0xb0/0xb0
 [&lt;ffffffff813855ae&gt;] ? trace_hardirqs_on_thunk+0x3a/0x3f
 [&lt;ffffffff810c5f57&gt;] SyS_init_module+0xd7/0x120
 [&lt;ffffffff817677c2&gt;] system_call_fastpath+0x16/0x1b

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Remove extra wakeup from pty write() path</title>
<updated>2013-07-24T16:29:56+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-07-24T12:29:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=5ede52538ee2b2202d9dff5b06c33bfde421e6e4'/>
<id>5ede52538ee2b2202d9dff5b06c33bfde421e6e4</id>
<content type='text'>
Acquiring the write_wait queue spin lock now accounts for the largest
slice of cpu time on the tty write path. Two factors contribute to
this situation; a overly-pessimistic line discipline write loop which
_always_ sets up a wait loop even if i/o will immediately succeed, and
on ptys, a wakeup storm from reads and writes.

Writer wakeup does not need to be performed by the pty driver.
Firstly, since the actual i/o is performed within the write, the
line discipline write loop will continue while space remains in
the flip buffers. Secondly, when space becomes avail in the
line discipline receive buffer (and thus also in the flip buffers),
the pty unthrottle re-wakes the writer (non-flow-controlled line
disciplines unconditionally unthrottle the driver when data is
received). Thus, existing in-kernel i/o is guaranteed to advance.
Finally, writer wakeup occurs at the conclusion of the line discipline
write (in tty_write_unlock()). This guarantees that any user-space write
waiters are woken to continue additional i/o.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Acquiring the write_wait queue spin lock now accounts for the largest
slice of cpu time on the tty write path. Two factors contribute to
this situation; a overly-pessimistic line discipline write loop which
_always_ sets up a wait loop even if i/o will immediately succeed, and
on ptys, a wakeup storm from reads and writes.

Writer wakeup does not need to be performed by the pty driver.
Firstly, since the actual i/o is performed within the write, the
line discipline write loop will continue while space remains in
the flip buffers. Secondly, when space becomes avail in the
line discipline receive buffer (and thus also in the flip buffers),
the pty unthrottle re-wakes the writer (non-flow-controlled line
disciplines unconditionally unthrottle the driver when data is
received). Thus, existing in-kernel i/o is guaranteed to advance.
Finally, writer wakeup occurs at the conclusion of the line discipline
write (in tty_write_unlock()). This guarantees that any user-space write
waiters are woken to continue additional i/o.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Track flip buffer memory limit atomically</title>
<updated>2013-07-23T23:47:08+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-15T13:36:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7bfe0b7116be207cf2204ae06335cc89d8f8ee02'/>
<id>7bfe0b7116be207cf2204ae06335cc89d8f8ee02</id>
<content type='text'>
Lockless flip buffers require atomically updating the bytes-in-use
watermark.

The pty driver also peeks at the watermark value to limit
memory consumption to a much lower value than the default; query
the watermark with new fn, tty_buffer_space_avail().

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Lockless flip buffers require atomically updating the bytes-in-use
watermark.

The pty driver also peeks at the watermark value to limit
memory consumption to a much lower value than the default; query
the watermark with new fn, tty_buffer_space_avail().

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Convert termios_mutex to termios_rwsem</title>
<updated>2013-07-23T23:43:01+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-15T13:14:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6a1c0680cf3ba94356ecd58833e1540c93472a57'/>
<id>6a1c0680cf3ba94356ecd58833e1540c93472a57</id>
<content type='text'>
termios is commonly accessed unsafely (especially by N_TTY)
because the existing mutex forces exclusive access.
Convert existing usage.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
termios is commonly accessed unsafely (especially by N_TTY)
because the existing mutex forces exclusive access.
Convert existing usage.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: Fix transient pty write() EIO</title>
<updated>2013-06-17T19:37:29+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-06-13T19:56:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7c61c3d8f44d5d822f758754287af644307b4af9'/>
<id>7c61c3d8f44d5d822f758754287af644307b4af9</id>
<content type='text'>
Commit 699390354da6c258b65bf8fa79cfd5feaede50b6
('pty: Ignore slave pty close() if never successfully opened')
introduced a bug with ptys whereby a write() in parallel with an
open() on an existing pty could mistakenly indicate an I/O error.

Only indicate an I/O error if the condition on open() actually exists.

Reported-by: Markus Trippelsdorf &lt;markus@trippelsdorf.de&gt;
Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Tested-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.9
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit 699390354da6c258b65bf8fa79cfd5feaede50b6
('pty: Ignore slave pty close() if never successfully opened')
introduced a bug with ptys whereby a write() in parallel with an
open() on an existing pty could mistakenly indicate an I/O error.

Only indicate an I/O error if the condition on open() actually exists.

Reported-by: Markus Trippelsdorf &lt;markus@trippelsdorf.de&gt;
Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Tested-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 3.9
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty: fix up atime/mtime mess, take three</title>
<updated>2013-05-01T14:32:21+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2013-05-01T14:32:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=b0b885657b6c8ef63a46bc9299b2a7715d19acde'/>
<id>b0b885657b6c8ef63a46bc9299b2a7715d19acde</id>
<content type='text'>
We first tried to avoid updating atime/mtime entirely (commit
b0de59b5733d: "TTY: do not update atime/mtime on read/write"), and then
limited it to only update it occasionally (commit 37b7f3c76595: "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: Simon Kirby &lt;sim@hostway.ca&gt;
Acked-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We first tried to avoid updating atime/mtime entirely (commit
b0de59b5733d: "TTY: do not update atime/mtime on read/write"), and then
limited it to only update it occasionally (commit 37b7f3c76595: "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: Simon Kirby &lt;sim@hostway.ca&gt;
Acked-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>TTY: pty, fix compilation warning</title>
<updated>2013-04-15T18:02:54+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jslaby@suse.cz</email>
</author>
<published>2013-04-15T05:52:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=f4b208eb91776b0522b41c78fac6cf08134db78f'/>
<id>f4b208eb91776b0522b41c78fac6cf08134db78f</id>
<content type='text'>
When CONFIG_UNIX98_PTYS is unset, we see this warning in pty:
  drivers/tty/pty.c:409:13: warning: ‘pty_unix98_shutdown’ defined but not used

Fix that by moving the function to a section which depends on that
config.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Toralf Foerster &lt;toralf.foerster@gmx.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When CONFIG_UNIX98_PTYS is unset, we see this warning in pty:
  drivers/tty/pty.c:409:13: warning: ‘pty_unix98_shutdown’ defined but not used

Fix that by moving the function to a section which depends on that
config.

Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Reported-by: Toralf Foerster &lt;toralf.foerster@gmx.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>pty: Remove redundant itty reset</title>
<updated>2013-03-15T20:00:48+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-02-05T21:08:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=19ffd68f816878aed456d5e87697f43bd9e3bd2b'/>
<id>19ffd68f816878aed456d5e87697f43bd9e3bd2b</id>
<content type='text'>
port-&gt;itty has already been reset by release_tty() before
pty_cleanup() is called.

Call stack:
release_tty()
  tty_kref_put()
    queue_release_one_tty()
      release_one_tty() : workqueue
        tty-&gt;ops-&gt;cleanup()
          pty_cleanup()

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
port-&gt;itty has already been reset by release_tty() before
pty_cleanup() is called.

Call stack:
release_tty()
  tty_kref_put()
    queue_release_one_tty()
      release_one_tty() : workqueue
        tty-&gt;ops-&gt;cleanup()
          pty_cleanup()

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>pty: Ignore slave open count for master pty open</title>
<updated>2013-02-04T23:40:29+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-01-30T17:43:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=80cace72566633bb99da1f022f71d3dac3498b02'/>
<id>80cace72566633bb99da1f022f71d3dac3498b02</id>
<content type='text'>
Multiple slave pty opens may be performed in parallel with the
master open. Of course, all the slave opens will fail because the
master pty is still locked but during this time the slave pty
count will be artificially greater than 1. This is should not
cause the master pty open to fail.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Multiple slave pty opens may be performed in parallel with the
master open. Of course, all the slave opens will fail because the
master pty is still locked but during this time the slave pty
count will be artificially greater than 1. This is should not
cause the master pty open to fail.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>pty: Ignore slave pty close() if never successfully opened</title>
<updated>2013-02-04T23:40:28+00:00</updated>
<author>
<name>Peter Hurley</name>
<email>peter@hurleysoftware.com</email>
</author>
<published>2013-01-30T17:43:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=699390354da6c258b65bf8fa79cfd5feaede50b6'/>
<id>699390354da6c258b65bf8fa79cfd5feaede50b6</id>
<content type='text'>
If the master and slave ptys are opened in parallel, the slave open
fails because the pty is still locked. This is as designed.
However, pty_close() is still called for the slave pty which sets
TTY_OTHER_CLOSED in the master pty. This can cause the master open
to fail as well.

Use a common pattern in other tty drivers by setting TTY_IO_ERROR
until the open is successful and only closing the pty if not set.

Note: the master pty always closes regardless of whether the open
was successful, so that proper cleanup can occur.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the master and slave ptys are opened in parallel, the slave open
fails because the pty is still locked. This is as designed.
However, pty_close() is still called for the slave pty which sets
TTY_OTHER_CLOSED in the master pty. This can cause the master open
to fail as well.

Use a common pattern in other tty drivers by setting TTY_IO_ERROR
until the open is successful and only closing the pty if not set.

Note: the master pty always closes regardless of whether the open
was successful, so that proper cleanup can occur.

Signed-off-by: Peter Hurley &lt;peter@hurleysoftware.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
