11 Jun, 2009

4 commits

  • There are several pretty much unfixable races in the old ldisc code, especially
    with respect to pty behaviour and also to hangup. It's easier to rewrite the
    code than simply try and patch it up.

    This patch
    - splits the ldisc from the tty (so we will be able to refcount it more cleanly
    later)
    - introduces a mutex lock for ldisc changing on an active device
    - fixes the complete mess that hangup caused
    - implements hopefully correct setldisc/close/hangup locking

    There are still some problems around pty pairs that have always been there but
    at least it is now possible to understand the code and fix further problems.

    This fixes the following known bugs
    - hang up can leak ldisc references
    - hang up may not call open/close on ldisc in a matched way
    - pty/tty pairs can deadlock during an ldisc change
    - reading the ldisc proc files can cause every ldisc to be loaded

    and probably a few other of the mysterious ldisc race reports.

    I'm sure it also adds the odd new one.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Before trying to tackle the ldisc bugs the code needs to be a good deal
    more readable, so do the simple extractions of routines first.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • We need this for devices that cannot flush and wait, but which do not order
    data and modem events. Without it we will hang up before all the data
    clears the hardware. Needed for the USB changes.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Some drivers implement this internally, others miss it out. Push the
    behaviour into the core code as that way everyone will do it consistently.

    Update the dtr rts method to raise or lower depending upon flags. Having a
    single method in this style fits most of the implementations more cleanly than
    two funtions.

    We need this in place before we tackle the USB side

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     

03 Jan, 2009

8 commits

  • Again this is a lot of common code we can unify

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Start sucking more commonality out of the drivers into a single piece of
    core code.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • This helps set the basis for moving block_til_ready into common code. We also
    introduce a tty_port_hangup helper as this will also be generally needed.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • This moves another per device special out of what should be shared open
    wait paths into private methods

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • This is the first step to generalising the various pieces of waiting logic
    duplicated in all sorts of serial drivers.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • We have special case logic for resizing pty/tty pairs. We also have a per
    driver resize method so for the pty case we should use it.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Fixes the loss of echoed (and other ldisc-generated characters) when
    the tty is stopped or when the driver output buffer is full (happens
    frequently for input during continuous program output, such as ^C)
    and removes the Big Kernel Lock from the N_TTY line discipline.

    Adds an "echo buffer" to the N_TTY line discipline that handles all
    ldisc-generated output (including echoed characters). Along with the
    loss of characters, this also fixes the associated loss of sync between
    tty output and the ldisc state when characters cannot be immediately
    written to the tty driver.

    The echo buffer stores (in addition to characters) state operations that need
    to be done at the time of character output (like management of the column
    position). This allows echo to cooperate correctly with program output,
    since the ldisc state remains consistent with actual characters written.

    Since the echo buffer code now isolates the tty column state code
    to the process_out* and process_echoes functions, we can remove the
    Big Kernel Lock (BKL) and replace it with mutex locks.

    Highlights are:

    * Handles echo (and other ldisc output) when tty driver buffer is full
    - continuous program output can block echo
    * Saves echo when tty is in stopped state (e.g. ^S)
    - (e.g.: ^Q will correctly cause held characters to be released for output)
    * Control character pairs (e.g. "^C") are treated atomically and not
    split up by interleaved program output
    * Line discipline state is kept consistent with characters sent to
    the tty driver
    * Remove the big kernel lock (BKL) from N_TTY line discipline

    Signed-off-by: Joe Peterson
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Joe Peterson
     

29 Dec, 2008

1 commit

  • …el/git/tip/linux-2.6-tip

    * 'tracing-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (241 commits)
    sched, trace: update trace_sched_wakeup()
    tracing/ftrace: don't trace on early stage of a secondary cpu boot, v3
    Revert "x86: disable X86_PTRACE_BTS"
    ring-buffer: prevent false positive warning
    ring-buffer: fix dangling commit race
    ftrace: enable format arguments checking
    x86, bts: memory accounting
    x86, bts: add fork and exit handling
    ftrace: introduce tracing_reset_online_cpus() helper
    tracing: fix warnings in kernel/trace/trace_sched_switch.c
    tracing: fix warning in kernel/trace/trace.c
    tracing/ring-buffer: remove unused ring_buffer size
    trace: fix task state printout
    ftrace: add not to regex on filtering functions
    trace: better use of stack_trace_enabled for boot up code
    trace: add a way to enable or disable the stack tracer
    x86: entry_64 - introduce FTRACE_ frame macro v2
    tracing/ftrace: add the printk-msg-only option
    tracing/ftrace: use preempt_enable_no_resched_notrace in ring_buffer_time_stamp()
    x86, bts: correctly report invalid bts records
    ...

    Fixed up trivial conflict in scripts/recordmcount.pl due to SH bits
    being already partly merged by the SH merge.

    Linus Torvalds
     

09 Dec, 2008

1 commit

  • AUDIT_TTY records currently log all data read by processes marked for
    TTY input auditing, even if the data was "pushed back" using the TIOCSTI
    ioctl, not typed by the user.

    This patch records all TIOCSTI calls to disambiguate the input. It
    generates one audit message per character pushed back; considering
    TIOCSTI is used very rarely, this simple solution is probably good
    enough. (The only program I could find that uses TIOCSTI is mailx/nail
    in "header editing" mode, e.g. using the ~h escape. mailx is used very
    rarely, and the escapes are used even rarer.)

    Signed-Off-By: Miloslav Trmac
    Signed-off-by: Al Viro
    Signed-off-by: James Morris

    Al Viro
     

25 Nov, 2008

1 commit

  • Stephen Rothwell reported tht this warning started triggering in
    linux-next:

    In file included from init/main.c:27:
    include/linux/tty.h: In function ‘tty_kref_get’:
    include/linux/tty.h:330: warning: ‘______f’ is static but declared in inline function ‘tty_kref_get’ which is not static

    Which gcc emits for 'extern inline' functions that nevertheless define
    static variables. Change it to 'static inline', which is the norm
    in the kernel anyway.

    Reported-by: Stephen Rothwell
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

14 Oct, 2008

11 commits

  • Move the set up on ldisc change into the ldisc
    Move the INQ/OUTQ cases into the driver not in shared ioctl code where it
    gives bogus answers for other ldisc values

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • The majority of the remaining init_dev code is pty special cases. We
    refactor this code into the driver->install method.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Original suggestion and proposal from Sukadev Bhattiprolu.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Carry on pushing code out of tty_io when it belongs to other drivers. I'm
    not 100% happy with some of this and it will be worth revisiting some of the
    exports later when the restructuring work is done.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Right now there are various drivers that try to use tty->count to know when
    they get the final close. Aristeau Rozanski showed while debugging the vt
    sysfs race that this isn't entirely safe.

    Instead of driver side tricks to work around this introduce a shutdown which
    is called when the tty is being destructed. This also means that the shutdown
    method is tied into the refcounting.

    Use this to rework the console close/sysfs logic.

    Remove lots of special case code from the tty core code. The pty code can now
    have a shutdown() method that replaces the special case hackery in the tree
    free up paths.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • We now have the infrastructure to sort this out but rather than teaching
    the syscall tty lock rules we move the hard work into a tty helper

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Use kref in the USB serial drivers so that we don't free tty structures
    from under the URB receive handlers as has historically been the case if
    you were unlucky. This also gives us a framework for general tty drivers to
    use tty_port objects and refcount.

    Contains two err->dev_err changes merged together to fix clashes in the
    -next tree.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • We need a way to describe the various additional modes and flow control
    features that random weird hardware shows up and software such as wine
    wants to emulate as Windows supports them.

    TCGETX/TCSETX and the termiox ioctl are a SYS5 extension that we might as
    well adopt. This patches adds the structures and the basic ioctl interfaces
    when the TCGETX etc defines are added for an architecture. Drivers wishing
    to use this stuff need to add new methods.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Introduce a kref to the tty structure and use it to protect the tty->signal
    tty references. For now we don't introduce it for anything else.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Add a new line discipline for "pulse per second" devices connected to
    a serial port.

    Signed-off-by: Rodolfo Giometti
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • The two are basically independent chunks of code so lets split them up for
    readability and sanity. It also makes the API boundaries much clearer.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     

16 Aug, 2008

1 commit

  • This moves it to being a tty operation. That removes special cases and now
    also means that resize can be picked up by um and other non vt consoles
    which may have a resize operation.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     

23 Jul, 2008

1 commit


21 Jul, 2008

4 commits

  • Move more bits into the tty_port structure

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Coding style clean up and white space tidy

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Every tty driver has its own concept of a port structure and because
    they all differ we cannot extract commonality. Begin fixing this by
    creating a structure drivers can elect to use so that over time we can
    push fields into this and create commonality and then introduce common
    methods.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Move the line disciplines towards a conventional ->ops arrangement. For
    the moment the actual 'tty_ldisc' struct in the tty is kept as part of
    the tty struct but this can then be changed if it turns out that when it
    all settles down we want to refcount ldiscs separately to the tty.

    Pull the ldisc code out of /proc and put it with our ldisc code.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     

07 Jun, 2008

1 commit


30 Apr, 2008

5 commits

  • Something Arjan suggested which allows us to clean up the code nicely

    Signed-off-by: Alan Cox
    Cc: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • - Operations are now a shared const function block as with most other Linux
    objects

    - Introduce wrappers for some optional functions to get consistent behaviour

    - Wrap put_char which used to be patched by the tty layer

    - Document which functions are needed/optional

    - Make put_char report success/fail

    - Cache the driver->ops pointer in the tty as tty->ops

    - Remove various surplus lock calls we no longer need

    - Remove proc_write method as noted by Alexey Dobriyan

    - Introduce some missing sanity checks where certain driver/ldisc
    combinations would oops as they didn't check needed methods were present

    [akpm@linux-foundation.org: fix fs/compat_ioctl.c build]
    [akpm@linux-foundation.org: fix isicom]
    [akpm@linux-foundation.org: fix arch/ia64/hp/sim/simserial.c build]
    [akpm@linux-foundation.org: fix kgdb]
    Signed-off-by: Alan Cox
    Acked-by: Greg Kroah-Hartman
    Cc: Jason Wessel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • This fixes the last couple of pid struct locking failures I know about.

    [oleg@tv-sign.ru: clean up do_task_stat()]
    Signed-off-by: Alan Cox
    Signed-off-by: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • Historically tty->pgrp and friends were pid_t and the code "knew" they were
    safe. The change to pid structs opened up a few races and the removal of the
    BKL in places made them quite hittable. We put tty->pgrp under the ctrl_lock
    for the tty.

    Signed-off-by: Alan Cox
    Cc: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • - Push the BKL down into the line disciplines
    - Switch the tty layer to unlocked_ioctl
    - Introduce a new ctrl_lock spin lock for the control bits
    - Eliminate much of the lock_kernel use in n_tty
    - Prepare to (but don't yet) call the drivers with the lock dropped
    on the paths that historically held the lock

    BKL now primarily protects open/close/ldisc change in the tty layer

    [jirislaby@gmail.com: a couple of fixes]
    Signed-off-by: Alan Cox
    Signed-off-by: Jiri Slaby
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alan Cox
     

28 Apr, 2008

2 commits

  • Remove the code that automatically disables TTY input auditing in processes
    that open TTYs when they have no other TTY open; this heuristic was
    intended to automatically handle daemons, but it has false positives (e.g.
    with sshd) that make it impossible to control TTY input auditing from a PAM
    module. With this patch, TTY input auditing is controlled from user-space
    only.

    On the other hand, not even for daemons does it make sense to audit "input"
    from PTY masters; this data was produced by a program writing to the PTY
    slave, and does not represent data entered by the user.

    Signed-off-by: Miloslav Trmac
    Cc: Al Viro
    Cc: David Woodhouse
    Signed-off-by: Andrew Morton
    Signed-off-by: Al Viro

    Miloslav Trmac
     
  • Previously I added sessionid output to all audit messages where it was
    available but we still didn't know the sessionid of the sender of
    netlink messages. This patch adds that information to netlink messages
    so we can audit who sent netlink messages.

    Signed-off-by: Eric Paris
    Signed-off-by: Al Viro

    Eric Paris