1. 23 Aug, 2011 1 commit
    • Jiri Slaby's avatar
      TTY: pty, fix pty counting · 24d406a6
      Jiri Slaby authored
      tty_operations->remove is normally called like:
      queue_release_one_tty
       ->tty_shutdown
         ->tty_driver_remove_tty
           ->tty_operations->remove
      
      However tty_shutdown() is called from queue_release_one_tty() only if
      tty_operations->shutdown is NULL. But for pty, it is not.
      pty_unix98_shutdown() is used there as ->shutdown.
      
      So tty_operations->remove of pty (i.e. pty_unix98_remove()) is never
      called. This results in invalid pty_count. I.e. what can be seen in
      /proc/sys/kernel/pty/nr.
      
      I see this was already reported at:
        https://lkml.org/lkml/2009/11/5/370
      
      
      But it was not fixed since then.
      
      This patch is kind of a hackish way. The problem lies in ->install. We
      allocate there another tty (so-called tty->link). So ->install is
      called once, but ->remove twice, for both tty and tty->link. The fix
      here is to count both tty and tty->link and divide the count by 2 for
      user.
      
      And to have ->remove called, let's make tty_driver_remove_tty() global
      and call that from pty_unix98_shutdown() (tty_operations->shutdown).
      
      While at it, let's document that when ->shutdown is defined,
      tty_shutdown() is not called.
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Cc: Alan Cox <alan@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      24d406a6
  2. 07 Jun, 2011 1 commit
  3. 13 May, 2011 1 commit
    • J Freyensee's avatar
      n_tracerouter and n_tracesink ldisc additions. · ee4f6b4b
      J Freyensee authored
      
      
      The n_tracerouter and n_tracesink line discpline drivers use the
      Linux tty line discpline framework to route trace data coming
      from a tty port (say UART for example) to the trace sink line
      discipline driver and to another tty port(say USB).  Those
      these two line discipline drivers can be used together,
      independently from pti.c, they are part of the original
      implementation solution of the MIPI P1149.7, compact JTAG, PTI
      solution for Intel mobile platforms starting with the
      Medfield platform.
      Signed-off-by: default avatarJ Freyensee <james_p_freyensee@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      ee4f6b4b
  4. 19 Apr, 2011 1 commit
    • Jiri Slaby's avatar
      TTY: introduce deinit helpers for proper ldisc shutdown · 6716671d
      Jiri Slaby authored
      
      
      Introduce deinitialize_tty_struct which should be called after
      initialize_tty_struct and before successfull tty_ldisc_setup.
      
      It calls tty_ldisc_deinit which is opposite of tty_ldisc_init. It only
      puts a reference to ldisc and assigns NULL to tty->ldisc.
      
      It will be used to shut down ldisc when tty_release cannot be called
      yet.
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Julian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      6716671d
  5. 22 Mar, 2011 1 commit
    • Linus Torvalds's avatar
      tty: stop using "delayed_work" in the tty layer · f23eb2b2
      Linus Torvalds authored
      
      
      Using delayed-work for tty flip buffers ends up causing us to wait for
      the next tick to complete some actions.  That's usually not all that
      noticeable, but for certain latency-critical workloads it ends up being
      totally unacceptable.
      
      As an extreme case of this, passing a token back-and-forth over a pty
      will take two ticks per iteration, so even just a thousand iterations
      will take 8 seconds assuming a common 250Hz configuration.
      
      Avoiding the whole delayed work issue brings that ping-pong test-case
      down to 0.009s on my machine.
      
      In more practical terms, this latency has been a performance problem for
      things like dive computer simulators (simulating the serial interface
      using the ptys) and for other environments (Alan mentions a CP/M emulator).
      Reported-by: default avatarJef Driesen <jefdriesen@telenet.be>
      Acked-by: default avatarGreg KH <gregkh@suse.de>
      Acked-by: default avatarAlan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f23eb2b2
  6. 17 Feb, 2011 3 commits
  7. 29 Nov, 2010 1 commit
    • Jiri Slaby's avatar
      TTY: open/hangup race fixup · acfa747b
      Jiri Slaby authored
      
      
      Like in the "TTY: don't allow reopen when ldisc is changing" patch,
      this one fixes a TTY WARNING as described in the option 1) there:
      1) __tty_hangup from tty_ldisc_hangup to tty_ldisc_enable. During this
      section tty_lock is held. However tty_lock is temporarily dropped in
      the middle of the function by tty_ldisc_hangup.
      
      The fix is to introduce a new flag which we set during the unlocked
      window and check it in tty_reopen too. The flag is TTY_HUPPING and is
      cleared after TTY_HUPPED is set.
      
      While at it, remove duplicate TTY_HUPPED set_bit. The one after
      calling ops->hangup seems to be more correct. But anyway, we hold
      tty_lock, so there should be no difference.
      
      Also document the function it does that kind of crap.
      
      Nicely reproducible with two forked children:
      static void do_work(const char *tty)
      {
      	if (signal(SIGHUP, SIG_IGN) == SIG_ERR) exit(1);
      	setsid();
      	while (1) {
      		int fd = open(tty, O_RDWR|O_NOCTTY);
      		if (fd < 0) continue;
      		if (ioctl(fd, TIOCSCTTY)) continue;
      		if (vhangup()) continue;
      		close(fd);
      	}
      	exit(0);
      }
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Reported-by: <Valdis.Kletnieks@vt.edu>
      Reported-by: default avatarKyle McMartin <kyle@mcmartin.ca>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      acfa747b
  8. 17 Nov, 2010 1 commit
  9. 09 Nov, 2010 1 commit
  10. 30 Oct, 2010 1 commit
    • Thomas Gleixner's avatar
      audit: Call tty_audit_push_task() outside preempt disabled · 3c80fe4a
      Thomas Gleixner authored
      
      
      While auditing all tasklist_lock read_lock sites I stumbled over the
      following call chain:
      
      audit_prepare_user_tty()
        read_lock(&tasklist_lock);
        tty_audit_push_task();
           mutex_lock(&buf->mutex);
      
           --> buf->mutex is locked with preemption disabled.
      
      Solve this by acquiring a reference to the task struct under
      rcu_read_lock and call tty_audit_push_task outside of the preempt
      disabled region.
      
      Move all code which needs to be protected by sighand lock into
      tty_audit_push_task() and use lock/unlock_sighand as we do not hold
      tasklist_lock.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      3c80fe4a
  11. 22 Oct, 2010 2 commits
  12. 05 Oct, 2010 1 commit
    • Pavan Savoy's avatar
      tty.h: new ldisc for TI WiLink ST · 40fb29a7
      Pavan Savoy authored
      
      
      Texas Instrument's WiLink7 connectivity devices pack wireless connectivity
      technologies like Bluetooth, FM Radio Receiver and Transmitter, GPS and WLAN
      into a single die.
      The BT, FM and GPS core on the chip are interfaced to application
      processors via a single UART.
      
      This line discipline driver allows such different technologies to be used
      simultaneous and independent of each other.
      Signed-off-by: default avatarPavan Savoy <pavan_savoy@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      40fb29a7
  13. 18 Aug, 2010 2 commits
    • Nick Piggin's avatar
      tty: fix fu_list abuse · d996b62a
      Nick Piggin authored
      
      
      tty: fix fu_list abuse
      
      tty code abuses fu_list, which causes a bug in remount,ro handling.
      
      If a tty device node is opened on a filesystem, then the last link to the inode
      removed, the filesystem will be allowed to be remounted readonly. This is
      because fs_may_remount_ro does not find the 0 link tty inode on the file sb
      list (because the tty code incorrectly removed it to use for its own purpose).
      This can result in a filesystem with errors after it is marked "clean".
      
      Taking idea from Christoph's initial patch, allocate a tty private struct
      at file->private_data and put our required list fields in there, linking
      file and tty. This makes tty nodes behave the same way as other device nodes
      and avoid meddling with the vfs, and avoids this bug.
      
      The error handling is not trivial in the tty code, so for this bugfix, I take
      the simple approach of using __GFP_NOFAIL and don't worry about memory errors.
      This is not a problem because our allocator doesn't fail small allocs as a rule
      anyway. So proper error handling is left as an exercise for tty hackers.
      
      [ Arguably filesystem's device inode would ideally be divorced from the
      driver's pseudo inode when it is opened, but in practice it's not clear whether
      that will ever be worth implementing. ]
      
      Cc: linux-kernel@vger.kernel.org
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: default avatarNick Piggin <npiggin@kernel.dk>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d996b62a
    • Nick Piggin's avatar
      fs: cleanup files_lock locking · ee2ffa0d
      Nick Piggin authored
      
      
      fs: cleanup files_lock locking
      
      Lock tty_files with a new spinlock, tty_files_lock; provide helpers to
      manipulate the per-sb files list; unexport the files_lock spinlock.
      
      Cc: linux-kernel@vger.kernel.org
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: default avatarNick Piggin <npiggin@kernel.dk>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      ee2ffa0d
  14. 10 Aug, 2010 5 commits
    • Arnd Bergmann's avatar
      tty: implement BTM as mutex instead of BKL · b07471fa
      Arnd Bergmann authored
      
      
      The tty locking now follows the rules for mutexes, so
      we can replace the BKL usage with a new subsystem
      wide mutex.
      
      Using a regular mutex here will change the behaviour
      when blocked on the BTM from spinning to sleeping,
      but that should not be visible to the user.
      
      Using the mutex also means that all the BTM is now
      covered by lockdep.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      b07471fa
    • Arnd Bergmann's avatar
      tty: remove tty_lock_nested · ddcd9fb6
      Arnd Bergmann authored
      
      
      This changes all remaining users of tty_lock_nested
      to be non-recursive, which lets us kill this function.
      As a consequence, we won't need to keep the lock count
      any more, which allows more simplifications later.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      ddcd9fb6
    • Arnd Bergmann's avatar
      tty: introduce wait_event_interruptible_tty · be1bc288
      Arnd Bergmann authored
      
      
      Calling wait_event_interruptible implicitly
      releases the BKL when it sleeps, but we need
      to do this explcitly when we have converted
      it to a mutex.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      be1bc288
    • Arnd Bergmann's avatar
      tty: replace BKL with a new tty_lock · ec79d605
      Arnd Bergmann authored
      
      
      As a preparation for replacing the big kernel lock
      in the TTY layer, wrap all the callers in new
      macros tty_lock, tty_lock_nested and tty_unlock.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      ec79d605
    • hyc@symas.com's avatar
      tty: Add EXTPROC support for LINEMODE · 26df6d13
      hyc@symas.com authored
      This patch is against the 2.6.34 source.
      
      Paraphrased from the 1989 BSD patch by David Borman @ cray.com:
      
           These are the changes needed for the kernel to support
           LINEMODE in the server.
      
           There is a new bit in the termios local flag word, EXTPROC.
           When this bit is set, several aspects of the terminal driver
           are disabled.  Input line editing, character echo, and mapping
           of signals are all disabled.  This allows the telnetd to turn
           off these functions when in linemode, but still keep track of
           what state the user wants the terminal to be in.
      
           New ioctl:
               TIOCSIG         Generate a signal to processes in the
                               current process group of the pty.
      
           There is a new mode for packet driver, the TIOCPKT_IOCTL bit.
           When packet mode is turned on in the pty, and the EXTPROC bit
           is set, then whenever the state of the pty is changed, the
           next read on the master side of the pty will have the TIOCPKT_IOCTL
           bit set.  This allows the process on the server side of the pty
           to know when the state of the terminal has changed; it can then
           issue the appropriate ioctl to retrieve the new state.
      
      Since the original BSD patches accompanied the source code for telnet
      I've left that reference here, but obviously the feature is useful for
      any remote terminal protocol, including ssh.
      
      The corresponding feature has existed in the BSD tty driver since 1989.
      For historical reference, a good copy of the relevant files can be found
      here:
      
      http://anonsvn.mit.edu/viewvc/krb5/trunk/src/appl/telnet/?pathrev=17741
      
      Signed-off-by: default avatarHoward Chu <hyc@symas.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      
      26df6d13
  15. 06 Aug, 2010 1 commit
    • David Howells's avatar
      Fix init ordering of /dev/console vs callers of modprobe · 31d1d48e
      David Howells authored
      
      
      Make /dev/console get initialised before any initialisation routine that
      invokes modprobe because if modprobe fails, it's going to want to open
      /dev/console, presumably to write an error message to.
      
      The problem with that is that if the /dev/console driver is not yet
      initialised, the chardev handler will call request_module() to invoke
      modprobe, which will fail, because we never compile /dev/console as a
      module.
      
      This will lead to a modprobe loop, showing the following in the kernel
      log:
      
      	request_module: runaway loop modprobe char-major-5-1
      	request_module: runaway loop modprobe char-major-5-1
      	request_module: runaway loop modprobe char-major-5-1
      	request_module: runaway loop modprobe char-major-5-1
      	request_module: runaway loop modprobe char-major-5-1
      
      This can happen, for example, when the built in md5 module can't find
      the built in cryptomgr module (because the latter fails to initialise).
      The md5 module comes before the call to tty_init(), presumably because
      'crypto' comes before 'drivers' alphabetically.
      
      Fix this by calling tty_init() from chrdev_init().
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      31d1d48e
  16. 21 May, 2010 2 commits
  17. 30 Mar, 2010 1 commit
  18. 19 Mar, 2010 2 commits
    • Jason Wessel's avatar
      tty_port,usb-console: Fix usb serial console open/close regression · 336cee42
      Jason Wessel authored
      Commit e1108a63
      
       ("usb_serial: Use the
      shutdown() operation") breaks the ability to use a usb console
      starting in 2.6.33.  This was observed when using
      console=ttyUSB0,115200 as a boot argument with an FTDI device.  The
      error is:
      
      ftdi_sio ttyUSB0: ftdi_submit_read_urb - failed submitting read urb, error -22
      
      The handling of the ASYNCB_INITIALIZED changed in 2.6.32 such that in
      tty_port_shutdown() it always clears the flag if it is set.  The fix
      is to add a variable to the tty_port struct to indicate when the tty
      port is a console.
      
      CC: Alan Cox <alan@linux.intel.com>
      CC: Alan Stern <stern@rowland.harvard.edu>
      CC: Oliver Neukum <oliver@neukum.org>
      CC: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      336cee42
    • Mel Gorman's avatar
      tty: Take a 256 byte padding into account when buffering below sub-page units · 352fa6ad
      Mel Gorman authored
      
      
      The TTY layer takes some care to ensure that only sub-page allocations
      are made with interrupts disabled. It does this by setting a goal of
      "TTY_BUFFER_PAGE" to allocate. Unfortunately, while TTY_BUFFER_PAGE takes the
      size of tty_buffer into account, it fails to account that tty_buffer_find()
      rounds the buffer size out to the next 256 byte boundary before adding on
      the size of the tty_buffer.
      
      This patch adjusts the TTY_BUFFER_PAGE calculation to take into account the
      size of the tty_buffer and the padding. Once applied, tty_buffer_alloc()
      should not require high-order allocations.
      Signed-off-by: default avatarMel Gorman <mel@csn.ul.ie>
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      352fa6ad
  19. 12 Mar, 2010 1 commit
  20. 02 Mar, 2010 1 commit
  21. 16 Jan, 2010 1 commit
  22. 15 Dec, 2009 1 commit
    • Bernhard Walle's avatar
      vt: introduce and use vt_kmsg_redirect() function · 5ada918b
      Bernhard Walle authored
      
      
      The kernel offers with TIOCL_GETKMSGREDIRECT ioctl() the possibility to
      redirect the kernel messages to a specific console.
      
      However, since it's not possible to switch to the kernel message console
      after a panic(), it would be nice if the kernel would print the panic
      message on the current console.
      
      This patch series adds a new interface to access the global kmsg_redirect
      variable by a function to be able to use it in code where
      CONFIG_VT_CONSOLE is not set (kernel/panic.c).
      
      This patch:
      
      Instead of using and exporting a global value kmsg_redirect, introduce a
      function vt_kmsg_redirect() that both can set and return the console where
      messages are printed.
      
      Change all users of kmsg_redirect (the VT code itself and kernel/power.c)
      to the new interface.
      
      The main advantage is that vt_kmsg_redirect() can also be used when
      CONFIG_VT_CONSOLE is not set.
      Signed-off-by: default avatarBernhard Walle <bernhard@bwalle.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5ada918b
  23. 11 Dec, 2009 4 commits
  24. 19 Sep, 2009 4 commits