1. 18 6月, 2013 1 次提交
  2. 21 5月, 2013 1 次提交
    • P
      tty/vt: Fix vc_deallocate() lock order · 421b40a6
      Peter Hurley 提交于
      Now that the tty port owns the flip buffers and i/o is allowed
      from the driver even when no tty is attached, the destruction
      of the tty port (and the flip buffers) must ensure that no
      outstanding work is pending.
      
      Unfortunately, this creates a lock order problem with the
      console_lock (see attached lockdep report [1] below).
      
      For single console deallocation, drop the console_lock prior
      to port destruction. When multiple console deallocation,
      defer port destruction until the consoles have been
      deallocated.
      
      tty_port_destroy() is not required if the port has not
      been used; remove from vc_allocate() failure path.
      
      [1] lockdep report from Dave Jones <davej@redhat.com>
      
       ======================================================
       [ INFO: possible circular locking dependency detected ]
       3.9.0+ #16 Not tainted
       -------------------------------------------------------
       (agetty)/26163 is trying to acquire lock:
       blocked:  ((&buf->work)){+.+...}, instance: ffff88011c8b0020, at: [<ffffffff81062065>] flush_work+0x5/0x2e0
      
       but task is already holding lock:
       blocked:  (console_lock){+.+.+.}, instance: ffffffff81c2fde0, at: [<ffffffff813bc201>] vt_ioctl+0xb61/0x1230
      
       which lock already depends on the new lock.
      
       the existing dependency chain (in reverse order) is:
      
       -> #1 (console_lock){+.+.+.}:
              [<ffffffff810b3f74>] lock_acquire+0xa4/0x210
              [<ffffffff810416c7>] console_lock+0x77/0x80
              [<ffffffff813c3dcd>] con_flush_chars+0x2d/0x50
              [<ffffffff813b32b2>] n_tty_receive_buf+0x122/0x14d0
              [<ffffffff813b7709>] flush_to_ldisc+0x119/0x170
              [<ffffffff81064381>] process_one_work+0x211/0x700
              [<ffffffff8106498b>] worker_thread+0x11b/0x3a0
              [<ffffffff8106ce5d>] kthread+0xed/0x100
              [<ffffffff81601cac>] ret_from_fork+0x7c/0xb0
      
       -> #0 ((&buf->work)){+.+...}:
              [<ffffffff810b349a>] __lock_acquire+0x193a/0x1c00
              [<ffffffff810b3f74>] lock_acquire+0xa4/0x210
              [<ffffffff810620ae>] flush_work+0x4e/0x2e0
              [<ffffffff81065305>] __cancel_work_timer+0x95/0x130
              [<ffffffff810653b0>] cancel_work_sync+0x10/0x20
              [<ffffffff813b8212>] tty_port_destroy+0x12/0x20
              [<ffffffff813c65e8>] vc_deallocate+0xf8/0x110
              [<ffffffff813bc20c>] vt_ioctl+0xb6c/0x1230
              [<ffffffff813b01a5>] tty_ioctl+0x285/0xd50
              [<ffffffff811ba825>] do_vfs_ioctl+0x305/0x530
              [<ffffffff811baad1>] sys_ioctl+0x81/0xa0
              [<ffffffff81601d59>] system_call_fastpath+0x16/0x1b
      
       other info that might help us debug this:
      
       [ 6760.076175]  Possible unsafe locking scenario:
      
              CPU0                    CPU1
              ----                    ----
         lock(console_lock);
                                      lock((&buf->work));
                                      lock(console_lock);
         lock((&buf->work));
      
        *** DEADLOCK ***
      
       1 lock on stack by (agetty)/26163:
        #0: blocked:  (console_lock){+.+.+.}, instance: ffffffff81c2fde0, at: [<ffffffff813bc201>] vt_ioctl+0xb61/0x1230
       stack backtrace:
       Pid: 26163, comm: (agetty) Not tainted 3.9.0+ #16
       Call Trace:
        [<ffffffff815edb14>] print_circular_bug+0x200/0x20e
        [<ffffffff810b349a>] __lock_acquire+0x193a/0x1c00
        [<ffffffff8100a269>] ? sched_clock+0x9/0x10
        [<ffffffff8100a269>] ? sched_clock+0x9/0x10
        [<ffffffff8100a200>] ? native_sched_clock+0x20/0x80
        [<ffffffff810b3f74>] lock_acquire+0xa4/0x210
        [<ffffffff81062065>] ? flush_work+0x5/0x2e0
        [<ffffffff810620ae>] flush_work+0x4e/0x2e0
        [<ffffffff81062065>] ? flush_work+0x5/0x2e0
        [<ffffffff810b15db>] ? mark_held_locks+0xbb/0x140
        [<ffffffff8113c8a3>] ? __free_pages_ok.part.57+0x93/0xc0
        [<ffffffff810b15db>] ? mark_held_locks+0xbb/0x140
        [<ffffffff810652f2>] ? __cancel_work_timer+0x82/0x130
        [<ffffffff81065305>] __cancel_work_timer+0x95/0x130
        [<ffffffff810653b0>] cancel_work_sync+0x10/0x20
        [<ffffffff813b8212>] tty_port_destroy+0x12/0x20
        [<ffffffff813c65e8>] vc_deallocate+0xf8/0x110
        [<ffffffff813bc20c>] vt_ioctl+0xb6c/0x1230
        [<ffffffff810aec41>] ? lock_release_holdtime.part.30+0xa1/0x170
        [<ffffffff813b01a5>] tty_ioctl+0x285/0xd50
        [<ffffffff812b00f6>] ? inode_has_perm.isra.46.constprop.61+0x56/0x80
        [<ffffffff811ba825>] do_vfs_ioctl+0x305/0x530
        [<ffffffff812b04db>] ? selinux_file_ioctl+0x5b/0x110
        [<ffffffff811baad1>] sys_ioctl+0x81/0xa0
        [<ffffffff81601d59>] system_call_fastpath+0x16/0x1b
      
      Cc: Dave Jones <davej@redhat.com>
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      421b40a6
  3. 22 11月, 2012 1 次提交
  4. 27 7月, 2012 1 次提交
    • R
      vt: fix race in vt_waitactive() · a7b12929
      Rabin Vincent 提交于
      pm_restore_console() is called from the suspend/resume path, and this
      calls vt_move_to_console(), which calls vt_waitactive().
      
      There's a race in this path which causes the process which requests the
      suspend to sleep indefinitely waiting for an event which already
      happened:
      
      P1                                      P2
       vt_move_to_console()
        set_console()
          schedule_console_callback()
        vt_waitactive()
          check n == fg_console +1
                                             console_callback()
                                               switch_screen()
                                               vt_event_post() // no waiters
      
          vt_event_wait() // forever
      
      Fix the race by ensuring we're registered for the event before we check
      if it's already completed.
      Signed-off-by: NRabin Vincent <rabin.vincent@stericsson.com>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7b12929
  5. 15 6月, 2012 1 次提交
    • R
      vt: fix race in vt_waitactive() · 2fc46915
      Rabin Vincent 提交于
      pm_restore_console() is called from the suspend/resume path, and this
      calls vt_move_to_console(), which calls vt_waitactive().
      
      There's a race in this path which causes the process which requests the
      suspend to sleep indefinitely waiting for an event which already
      happened:
      
      P1                                      P2
       vt_move_to_console()
        set_console()
          schedule_console_callback()
        vt_waitactive()
          check n == fg_console +1
                                             console_callback()
                                               switch_screen()
                                               vt_event_post() // no waiters
      
          vt_event_wait() // forever
      
      Fix the race by ensuring we're registered for the event before we check
      if it's already completed.
      Signed-off-by: NRabin Vincent <rabin.vincent@stericsson.com>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2fc46915
  6. 25 4月, 2012 1 次提交
  7. 09 3月, 2012 4 次提交
  8. 25 2月, 2012 1 次提交
  9. 04 2月, 2012 1 次提交
  10. 03 2月, 2012 1 次提交
  11. 20 4月, 2011 4 次提交
  12. 02 3月, 2011 1 次提交
  13. 18 2月, 2011 3 次提交
  14. 26 1月, 2011 1 次提交
    • T
      console: rename acquire/release_console_sem() to console_lock/unlock() · ac751efa
      Torben Hohn 提交于
      The -rt patches change the console_semaphore to console_mutex.  As a
      result, a quite large chunk of the patches changes all
      acquire/release_console_sem() to acquire/release_console_mutex()
      
      This commit makes things use more neutral function names which dont make
      implications about the underlying lock.
      
      The only real change is the return value of console_trylock which is
      inverted from try_acquire_console_sem()
      
      This patch also paves the way to switching console_sem from a semaphore to
      a mutex.
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: make console_trylock return 1 on success, per Geert]
      Signed-off-by: NTorben Hohn <torbenh@gmx.de>
      Cc: Thomas Gleixner <tglx@tglx.de>
      Cc: Greg KH <gregkh@suse.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ac751efa
  15. 05 11月, 2010 1 次提交
  16. 28 10月, 2010 1 次提交
  17. 29 8月, 2010 1 次提交
    • A
      Input: use PIT_TICK_RATE in vt beep ioctl · 2c4e9671
      Arnd Bergmann 提交于
      The KIOCSOUND and KDMKTONE ioctls are based on the CLOCK_TICK_RATE,
      which is architecture and sometimes configuration specific.
      
      In practice, most user applications assume that it is actually defined
      as the i8253 PIT base clock of 1193182 Hz, which is true on some
      architectures but not on others.
      
      This patch makes the vt code use the PIT frequency on all
      architectures, which is much more well-defined.  It will change the
      behavior of user applications sending the beep ioctl on all
      architectures that define CLOCK_TICK_RATE different from
      PIT_TICK_RATE.
      
      The original breakage was introduced in commit bcc8ca09 "Adapt
      drivers/char/vt_ioctl.c to non-x86".  Hopefully, reverting this change
      will make the frequency correct in more cases than it will make it
      incorrect.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NAlan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
      2c4e9671
  18. 11 8月, 2010 3 次提交
  19. 05 6月, 2010 1 次提交
  20. 19 3月, 2010 1 次提交
    • G
      Revert "tty: Add a new VT mode which is like VT_PROCESS but doesn't require a... · 87a6aca5
      Greg Kroah-Hartman 提交于
      Revert "tty: Add a new VT mode which is like VT_PROCESS but doesn't require a VT_RELDISP ioctl call"
      
      This reverts commit eec9fe7d.
      
      Ari writes as the reason this should be reverted:
      	The problems with this patch include:
      	1. There's at least one subtlety I overlooked - switching
      	between X servers (i.e. from one X VT to another) still requires
      	the cooperation of both X servers. I was assuming that KMS
      	eliminated this.
      	2. It hasn't been tested at all (no X server patch exists which
      	uses the new mode).
      
      As he was the original author of the patch, I'll revert it.
      
      Cc: Ari Entlich <atrigent@ccs.neu.edu>
      Cc: Alan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      87a6aca5
  21. 03 3月, 2010 1 次提交
    • A
      tty: Add a new VT mode which is like VT_PROCESS but doesn't require a VT_RELDISP ioctl call · eec9fe7d
      Ari Entlich 提交于
      This new VT mode (VT_PROCESS_AUTO) does everything that VT_PROCESS does
      except that it doesn't wait for a VT_RELDISP ioctl before switching
      away from a VT with that mode.
      
      If the X server eventually uses this new mode, debugging and crash
      recovery should become easier. This is because even when currently in
      the VT of a frozen X server it would still be possible to switch out
      by doing SysRq-r and then CTRL-<number of a text vt>, sshing in and
      doing chvt <number of a text vt>, or any other method of VT switching.
      The general concensus on #xorg-devel seems to be that it should be
      safe to use this with X now that we have KMS.
      
      This also moves the VT_ACKACQ define to a more appropriate place,
      for clarity's sake.
      Signed-off-by: NAri Entlich <atrigent@ccs.neu.edu>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      eec9fe7d
  22. 20 11月, 2009 1 次提交
  23. 15 10月, 2009 1 次提交
  24. 02 10月, 2009 1 次提交
  25. 20 9月, 2009 5 次提交
  26. 13 7月, 2009 1 次提交