1. 25 2月, 2012 2 次提交
  2. 03 2月, 2012 2 次提交
  3. 25 1月, 2012 2 次提交
  4. 18 11月, 2011 1 次提交
  5. 19 10月, 2011 2 次提交
    • J
      TTY: pty, release tty in all ptmx_open fail paths · 1177c0ef
      Jiri Slaby 提交于
      Mistakenly, commit 64ba3dc3 (tty: never hold BTM while getting
      tty_mutex) switched one fail path in ptmx_open to not free the newly
      allocated tty.
      
      Fix that by jumping to the appropriate place. And rename the labels so
      that it's clear what is going on there.
      
      Introduced-in: v2.6.36-rc2
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Cc: stable <stable@vger.kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1177c0ef
    • J
      TTY: make tty_add_file non-failing · fa90e1c9
      Jiri Slaby 提交于
      If tty_add_file fails at the point it is now, we have to revert all
      the changes we did to the tty. It means either decrease all refcounts
      if this was a tty reopen or delete the tty if it was newly allocated.
      
      There was a try to fix this in v3.0-rc2 using tty_release in 0259894c
      (TTY: fix fail path in tty_open). But instead it introduced a NULL
      dereference. It's because tty_release dereferences
      filp->private_data, but that one is set even in our tty_add_file. And
      when tty_add_file fails, it's still NULL/garbage. Hence tty_release
      cannot be called there.
      
      To circumvent the original leak (and the current NULL deref) we split
      tty_add_file into two functions, making the latter non-failing. In
      that case we may do the former early in open, where handling failures
      is easy. The latter stays as it is now. So there is no change in
      functionality.
      
      The original bug (leak) was introduced by f573bd17 (tty: Remove
      __GFP_NOFAIL from tty_add_file()). Thanks Dan for reporting this.
      
      Later, we may split tty_release into more functions and call only some
      of them in this fail path instead. (If at all possible.)
      
      Introduced-in: v2.6.37-rc2
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Cc: stable <stable@vger.kernel.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Pekka Enberg <penberg@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      fa90e1c9
  6. 24 8月, 2011 1 次提交
    • J
      TTY: pty, fix pty counting · 24d406a6
      Jiri Slaby 提交于
      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: NJiri 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: NGreg Kroah-Hartman <gregkh@suse.de>
      24d406a6
  7. 20 4月, 2011 4 次提交
  8. 02 3月, 2011 1 次提交
  9. 18 2月, 2011 1 次提交
  10. 05 11月, 2010 1 次提交
  11. 23 10月, 2010 1 次提交
  12. 18 8月, 2010 2 次提交
    • N
      tty: fix fu_list abuse · d996b62a
      Nick Piggin 提交于
      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: NNick Piggin <npiggin@kernel.dk>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      d996b62a
    • N
      fs: cleanup files_lock locking · ee2ffa0d
      Nick Piggin 提交于
      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: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: NNick Piggin <npiggin@kernel.dk>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      ee2ffa0d
  13. 11 8月, 2010 5 次提交
    • A
      tty: avoid recursive BTM in pty_close · 11dbf203
      Arnd Bergmann 提交于
      When the console has been redirected, a hangup of the tty
      will cause tty_release to be called under the big tty_mutex,
      which leads to a deadlock because hangup is also called
      under the BTM.
      
      This moves the BTM deeper into the tty_hangup function so
      we can close the redirected tty without holding the BTM.
      In case of pty, we now need to drop the BTM before
      calling tty_vhangup.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NAlan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: John Kacur <jkacur@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      11dbf203
    • A
      tty: remove tty_lock_nested · ddcd9fb6
      Arnd Bergmann 提交于
      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: NArnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ddcd9fb6
    • A
      tty: never hold BTM while getting tty_mutex · 64ba3dc3
      Arnd Bergmann 提交于
      tty_mutex is never taken with the BTM held, except for
      two corner cases that are worked around here.
      We give up the BTM before calling tty_release() in the
      error path of tty_open().
      Similarly, we reorder the locking in ptmx_open()
      to get tty_mutex before the BTM.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      64ba3dc3
    • A
      tty: replace BKL with a new tty_lock · ec79d605
      Arnd Bergmann 提交于
      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: NArnd Bergmann <arnd@arndb.de>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      ec79d605
    • H
      tty: Add EXTPROC support for LINEMODE · 26df6d13
      hyc@symas.com 提交于
      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=17741Signed-off-by: NHoward Chu <hyc@symas.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      26df6d13
  14. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  15. 09 2月, 2010 1 次提交
  16. 12 12月, 2009 1 次提交
  17. 19 11月, 2009 1 次提交
  18. 12 11月, 2009 1 次提交
    • E
      sysctl drivers: Remove dead binary sysctl support · 894d2491
      Eric W. Biederman 提交于
      Now that sys_sysctl is a wrapper around /proc/sys all of
      the binary sysctl support elsewhere in the tree is
      dead code.
      
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Corey Minyard <minyard@acm.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: Matt Mackall <mpm@selenic.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Neil Brown <neilb@suse.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
      Acked-by: Clemens Ladisch <clemens@ladisch.de> for drivers/char/hpet.c
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      894d2491
  19. 12 10月, 2009 1 次提交
  20. 30 9月, 2009 1 次提交
    • L
      pty: reconnect the BSD TIOCSPTLCK handling to legacy ptys · 342a5971
      Linus Torvalds 提交于
      David Howells noticed (due to the compiler warning about an unused
      'pty_ops_bsd' variable) that we haven't actually been using the code
      that implements TIOCSPTLCK for legacy pty handling.  It's been that way
      since 2.6.26, commit 3e8e88ca to be
      exact ("pty: prepare for tty->ops changes").
      
      DavidH initially submitted a patch just removing the dead code entirely,
      and since nobody has apparently ever complained, I'm not entirely sure
      that wouldn't be the right thing to do.  But since the whole and only
      point of the legacy pty code is to be compatible with legacy distros
      that don't use the new unix98 pty model, let's just wire it up again.
      
      And clean it up a bit while we're at it.
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      342a5971
  21. 18 9月, 2009 1 次提交
    • L
      pty_write: don't do a tty_wakeup() when the buffers are full · 202c4675
      Linus Torvalds 提交于
      Commit ac89a917 ("pty: don't limit the writes to 'pty_space()' inside
      'pty_write()'") removed the pty_space() checking, in order to let the
      regular tty buffer code limit the buffering itself.
      
      That was all good, but as a subtle side effect it meant that we'd be
      doing a tty_wakeup() even in the case where the buffers were all filled
      up, and didn't actually make any progress on the write.
      
      Which sounds innocuous, but it interacts very badly with the ppp_async
      code, which has an infinite loop in ppp_async_push() that tries to push
      out data to the tty.  When we call tty_wakeup(), that loop ends up
      thinking that progress was made (see the subtle interactions between
      XMIT_WAKEUP and 'tty_stuffed' for details).  End result: one unhappy ppp
      user.
      
      Fixed by noticing when tty_insert_flip_string() didn't actually do
      anything, and then not doing any more processing (including, very much
      not calling tty_wakeup()).
      Bisected-and-tested-by: NPeter Volkov <pva@gentoo.org>
      Cc: stable@kernel.org (2.6.31)
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      202c4675
  22. 06 9月, 2009 1 次提交
  23. 11 8月, 2009 1 次提交
    • L
      pty: fix data loss when stopped (^S/^Q) · 85dfd81d
      Linus Torvalds 提交于
      Commit d945cb9c ("pty: Rework the pty layer to use the normal buffering
      logic") dropped the test for 'tty->stopped' in pty_write_room(), which
      then causes the n_tty line discipline thing to not throttle the data
      properly when the tty is stopped.
      
      So instead of pausing the write due to the tty being stopped, the ldisc
      layer would go ahead and push it down to the pty.  The pty write()
      routine would then refuse to take the data (because it _did_ check
      'stopped'), and the data wouldn't actually be written.
      
      This whole stopped test should eventually be moved into the tty ldisc
      layer rather than have low-level tty drivers care about these things,
      but right now the fix is to just re-instate the missing pty 'stopped'
      handling.
      Reported-and-tested-by: NArtur Skawina <art.08.09@gmail.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      85dfd81d
  24. 30 7月, 2009 1 次提交
    • O
      pty: avoid forcing 'low_latency' tty flag · e043e42b
      OGAWA Hirofumi 提交于
      We really don't want to mark the pty as a low-latency device, because as
      Alan points out, the ->write method can be called from an IRQ (ppp?),
      and that means we can't use ->low_latency=1 as we take mutexes in the
      low_latency case.
      
      So rather than using low_latency to force the written data to be pushed
      to the ldisc handling at 'write()' time, just make the reader side (or
      the poll function) do the flush when it checks whether there is data to
      be had.
      
      This also fixes the problem with lost data in an emacs compile buffer
      (bugzilla 13815), and we can thus revert the low_latency pty hack
      (commit 3a542974: "pty: quickfix for the
      pty ENXIO timing problems").
      Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Tested-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      [ Modified to do the tty_flush_to_ldisc() inside input_available_p() so
        that it triggers for both read and poll()  - Linus]
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e043e42b
  25. 28 7月, 2009 1 次提交
  26. 13 7月, 2009 1 次提交
  27. 09 7月, 2009 1 次提交
  28. 17 6月, 2009 1 次提交