1. 09 5月, 2007 1 次提交
    • E
      tty: introduce no_tty and use it in selinux · 98a27ba4
      Eric W. Biederman 提交于
      While researching the tty layer pid leaks I found a weird case in selinux when
      we drop a controlling tty because of inadequate permissions we don't do the
      normal hangup processing.  Which is a problem if it happens the session leader
      has exec'd something that can no longer access the tty.
      
      We already have code in the kernel to handle this case in the form of the
      TIOCNOTTY ioctl.  So this patch factors out a helper function that is the
      essence of that ioctl and calls it from the selinux code.
      
      This removes the inconsistency in handling dropping of a controlling tty and
      who knows it might even make some part of user space happy because it received
      a SIGHUP it was expecting.
      
      In addition since this removes the last user of proc_set_tty outside of
      tty_io.c proc_set_tty is made static and removed from tty.h
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Acked-by: NAlan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: James Morris <jmorris@namei.org>
      Cc: Stephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      98a27ba4
  2. 13 2月, 2007 3 次提交
    • E
      [PATCH] tty: update the tty layer to work with struct pid · ab521dc0
      Eric W. Biederman 提交于
      Of kernel subsystems that work with pids the tty layer is probably the largest
      consumer.  But it has the nice virtue that the assiation with a session only
      lasts until the session leader exits.  Which means that no reference counting
      is required.  So using struct pid winds up being a simple optimization to
      avoid hash table lookups.
      
      In the long term the use of pid_nr also ensures that when we have multiple pid
      spaces mixed everything will work correctly.
      Signed-off-by: NEric W. Biederman <eric@maxwell.lnxi.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ab521dc0
    • E
      [PATCH] pid: replace is_orphaned_pgrp with is_current_pgrp_orphaned · 3e7cd6c4
      Eric W. Biederman 提交于
      Every call to is_orphaned_pgrp passed in process_group(current) which is racy
      with respect to another thread changing our process group.  It didn't bite us
      because we were dealing with integers and the worse we would get would be a
      stale answer.
      
      In switching the checks to use struct pid to be a little more efficient and
      prepare the way for pid namespaces this race became apparent.
      
      So I simplified the calls to the more specialized is_current_pgrp_orphaned so
      I didn't have to worry about making logic changes to avoid the race.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3e7cd6c4
    • E
      [PATCH] tty: make __proc_set_tty static · cdc62330
      Eric W. Biederman 提交于
      The aim of this patch set is to start wrapping up the struct pid conversions.
      As such this patchset culminates with the removal of kill_pg, kill_pg_info,
      __kill_pg_info, do_each_task_pid, and while_each_task_pid.
      
      kill_proc, daemonize, and kernel_thread are still in my sights but there is
      still work to get to them.
      
      The first three are basic cleanups around disassociate_ctty, while working on
      converting it I found several issues.  tty_old_pgrp can be a tricky concept to
      wrap your head around.
      
       1 tty: Make __proc_set_tty static.
       2 tty: Clarify disassociate_ctty
       3 tty: Fix the locking for signal->session in disassociate_ctty
      
      These just stop using the old helper functions.
      
       4 signal: Use kill_pgrp not kill_pg in the sunos compatibility code.
       5 signal: Rewrite kill_something_info so it uses newer helpers.
      
      Then the grind to convert the tty layer and all of it's helper functions to
      struct pid.
      
       6 pid: Make session_of_pgrp use struct pid instead of pid_t.
       7 pid: Use struct pid for talking about process groups in exit.c
       8 pid: Replace is_orphaned_pgrp with is_current_pgrp_orphaned
       9 tty: Update the tty layer to work with struct pid.
      
      A final helper function update.
      
      10 pid: Replace do/while_each_task_pid with do/while_each_pid_task
      
      And the removal of the functions that are now unused.
      11 pid: Remove now unused do_each_task_pid and while_each_task_pid
      12 pid: Remove the now unused kill_pg kill_pg_info and __kill_pg_info
      
      All of these should be fairly simple and to the point.
      
      This patch:
      
      Currently all users of __proc_set_tty are in tty_io.c so make the function
      static.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cdc62330
  3. 12 2月, 2007 2 次提交
    • T
      [PATCH] consolidate line discipline number definitions · 4564f9e5
      Tilman Schmidt 提交于
      The line discipline numbers N_* are currently defined for each architecture
      individually, but (except for a seeming mistake) identically, in
      asm/termios.h.  There is no obvious reason why these numbers should be
      architecture specific, nor any apparent relationship with the termios
      structure.  The total number of these, NR_LDISCS, is defined in linux/tty.h
      anyway.  So I propose the following patch which moves the definitions of
      the individual line disciplines to linux/tty.h too.
      
      Three of these numbers (N_MASC, N_PROFIBUS_FDL, and N_SMSBLOCK) are unused
      in the current kernel, but the patch still keeps the complete set in case
      there are plans to use them yet.
      Signed-off-by: NTilman Schmidt <tilman@imap.cc>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4564f9e5
    • E
      [PATCH] vt: refactor console SAK processing · 8b6312f4
      Eric W. Biederman 提交于
      This does several things.
      - It moves looking up of the current foreground console into process
        context where we can safely take the semaphore that protects this
        operation.
      - It uses the new flavor of work queue processing.
      - This generates a factor of do_SAK, __do_SAK that runs immediately.
      - This calls __do_SAK with the console semaphore held ensuring nothing
        else happens to the console while we process the SAK operation.
      - With the console SAK processing moved into process context this
        patch removes the xchg operations that I used to attempt to attomically
        update struct pid, because of the strange locking used in the SAK processing.
        With SAK using the normal console semaphore nothing special is needed.
      
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8b6312f4
  4. 09 12月, 2006 2 次提交
    • A
      [PATCH] tty: switch to ktermios and new framework · edc6afc5
      Alan Cox 提交于
      This is the core of the switch to the new framework.  I've split it from the
      driver patches which are mostly search/replace and would encourage people to
      give this one a good hard stare.
      
      The references to BOTHER and ISHIFT are the termios values that must be
      defined by a platform once it wants to turn on "new style" ioctl support.  The
      code patches here ensure that providing
      
      1. The termios overlays the ktermios in memory
      2. The only new kernel only fields are c_ispeed/c_ospeed (or none)
      
      the existing behaviour is retained.  This is true for the patches at this
      point in time.
      
      Future patches will define BOTHER, ISHIFT and enable newer termios structures
      for each architecture, and once they are all done some of the ifdefs also
      vanish.
      
      [akpm@osdl.org: warning fix]
      [akpm@osdl.org: IRDA fix]
      Signed-off-by: NAlan Cox <alan@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      edc6afc5
    • P
      [PATCH] tty: ->signal->tty locking · 24ec839c
      Peter Zijlstra 提交于
      Fix the locking of signal->tty.
      
      Use ->sighand->siglock to protect ->signal->tty; this lock is already used
      by most other members of ->signal/->sighand.  And unless we are 'current'
      or the tasklist_lock is held we need ->siglock to access ->signal anyway.
      
      (NOTE: sys_unshare() is broken wrt ->sighand locking rules)
      
      Note that tty_mutex is held over tty destruction, so while holding
      tty_mutex any tty pointer remains valid.  Otherwise the lifetime of ttys
      are governed by their open file handles.  This leaves some holes for tty
      access from signal->tty (or any other non file related tty access).
      
      It solves the tty SLAB scribbles we were seeing.
      
      (NOTE: the change from group_send_sig_info to __group_send_sig_info needs to
             be examined by someone familiar with the security framework, I think
             it is safe given the SEND_SIG_PRIV from other __group_send_sig_info
             invocations)
      
      [schwidefsky@de.ibm.com: 3270 fix]
      [akpm@osdl.org: various post-viro fixes]
      Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Acked-by: NAlan Cox <alan@redhat.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Chris Wright <chrisw@sous-sol.org>
      Cc: Roland McGrath <roland@redhat.com>
      Cc: Stephen Smalley <sds@tycho.nsa.gov>
      Cc: James Morris <jmorris@namei.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Jan Kara <jack@ucw.cz>
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      24ec839c
  5. 02 12月, 2006 1 次提交
  6. 22 11月, 2006 1 次提交
    • D
      WorkStruct: Separate delayable and non-delayable events. · 52bad64d
      David Howells 提交于
      Separate delayable work items from non-delayable work items be splitting them
      into a separate structure (delayed_work), which incorporates a work_struct and
      the timer_list removed from work_struct.
      
      The work_struct struct is huge, and this limits it's usefulness.  On a 64-bit
      architecture it's nearly 100 bytes in size.  This reduces that by half for the
      non-delayable type of event.
      Signed-Off-By: NDavid Howells <dhowells@redhat.com>
      52bad64d
  7. 01 10月, 2006 1 次提交
  8. 30 9月, 2006 2 次提交
  9. 28 8月, 2006 1 次提交
  10. 11 7月, 2006 2 次提交
  11. 29 6月, 2006 2 次提交
    • P
      [PATCH] remove active field from tty buffer structure · 33b37a33
      Paul Fulghum 提交于
      Remove 'active' field from tty buffer structure.  This was added in 2.6.16
      as part of a patch to make the new tty buffering SMP safe.  This field is
      unnecessary with the more intelligently written flush_to_ldisc that adds
      receive_room handling.
      
      Removing this field reverts to simpler logic where the tail buffer is
      always the 'active' buffer, which should not be freed by flush_to_ldisc.
      (active == buffer being filled with new data)
      
      The result is simpler, smaller, and faster tty buffer code.
      Signed-off-by: NPaul Fulghum <paulkf@microgate.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      33b37a33
    • P
      [PATCH] remove TTY_DONT_FLIP · 817d6d3b
      Paul Fulghum 提交于
      Remove TTY_DONT_FLIP tty flag.  This flag was introduced in 2.1.X kernels
      to prevent the N_TTY line discipline functions read_chan() and
      n_tty_receive_buf() from running at the same time.  2.2.15 introduced
      tty->read_lock to protect access to the N_TTY read buffer, which is the
      only state requiring protection between these two functions.
      
      The current TTY_DONT_FLIP implementation is broken for SMP, and is not
      universally honored by drivers that send data directly to the line
      discipline receive_buf function.
      
      Because TTY_DONT_FLIP is not necessary, is broken in implementation, and is
      not universally honored, it is removed.
      Signed-off-by: NPaul Fulghum <paulkf@microgate.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      817d6d3b
  12. 22 6月, 2006 1 次提交
  13. 26 4月, 2006 1 次提交
  14. 23 3月, 2006 1 次提交
  15. 11 2月, 2006 1 次提交
  16. 04 2月, 2006 1 次提交
    • P
      [PATCH] new tty buffering locking fix · 808249ce
      Paul Fulghum 提交于
      Change locking in the new tty buffering facility from using tty->read_lock,
      which is currently ignored by drivers and thus ineffective.  New locking
      uses a new tty buffering specific lock enforced centrally in the tty
      buffering code.
      
      Two drivers (esp and cyclades) are updated to use the tty buffering
      functions instead of accessing tty buffering internals directly.  This is
      required for the new locking to work.
      
      Minor checks for NULL buffers added to
      tty_prepare_flip_string/tty_prepare_flip_string_flags
      Signed-off-by: NPaul Fulghum <paulkf@microgate.com>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      808249ce
  17. 11 1月, 2006 1 次提交
    • A
      [PATCH] TTY layer buffering revamp · 33f0f88f
      Alan Cox 提交于
      The API and code have been through various bits of initial review by
      serial driver people but they definitely need to live somewhere for a
      while so the unconverted drivers can get knocked into shape, existing
      drivers that have been updated can be better tuned and bugs whacked out.
      
      This replaces the tty flip buffers with kmalloc objects in rings. In the
      normal situation for an IRQ driven serial port at typical speeds the
      behaviour is pretty much the same, two buffers end up allocated and the
      kernel cycles between them as before.
      
      When there are delays or at high speed we now behave far better as the
      buffer pool can grow a bit rather than lose characters. This also means
      that we can operate at higher speeds reliably.
      
      For drivers that receive characters in blocks (DMA based, USB and
      especially virtualisation) the layer allows a lot of driver specific
      code that works around the tty layer with private secondary queues to be
      removed. The IBM folks need this sort of layer, the smart serial port
      people do, the virtualisers do (because a virtualised tty typically
      operates at infinite speed rather than emulating 9600 baud).
      
      Finally many drivers had invalid and unsafe attempts to avoid buffer
      overflows by directly invoking tty methods extracted out of the innards
      of work queue structs. These are no longer needed and all go away. That
      fixes various random hangs with serial ports on overflow.
      
      The other change in here is to optimise the receive_room path that is
      used by some callers. It turns out that only one ldisc uses receive room
      except asa constant and it updates it far far less than the value is
      read. We thus make it a variable not a function call.
      
      I expect the code to contain bugs due to the size alone but I'll be
      watching and squashing them and feeding out new patches as it goes.
      
      Because the buffers now dynamically expand you should only run out of
      buffering when the kernel runs out of memory for real.  That means a lot of
      the horrible hacks high performance drivers used to do just aren't needed any
      more.
      
      Description:
      
      tty_insert_flip_char is an old API and continues to work as before, as does
      tty_flip_buffer_push() [this is why many drivers dont need modification].  It
      does now also return the number of chars inserted
      
      There are also
      
      tty_buffer_request_room(tty, len)
      
      which asks for a buffer block of the length requested and returns the space
      found.  This improves efficiency with hardware that knows how much to
      transfer.
      
      and tty_insert_flip_string_flags(tty, str, flags, len)
      
      to insert a string of characters and flags
      
      For a smart interface the usual code is
      
          len = tty_request_buffer_room(tty, amount_hardware_says);
          tty_insert_flip_string(tty, buffer_from_card, len);
      
      More description!
      
      At the moment tty buffers are attached directly to the tty.  This is causing a
      lot of the problems related to tty layer locking, also problems at high speed
      and also with bursty data (such as occurs in virtualised environments)
      
      I'm working on ripping out the flip buffers and replacing them with a pool of
      dynamically allocated buffers.  This allows both for old style "byte I/O"
      devices and also helps virtualisation and smart devices where large blocks of
      data suddenely materialise and need storing.
      
      So far so good.  Lots of drivers reference tty->flip.*.  Several of them also
      call directly and unsafely into function pointers it provides.  This will all
      break.  Most drivers can use tty_insert_flip_char which can be kept as an API
      but others need more.
      
      At the moment I've added the following interfaces, if people think more will
      be needed now is a good time to say
      
       int tty_buffer_request_room(tty, size)
      
      Try and ensure at least size bytes are available, returns actual room (may be
      zero).  At the moment it just uses the flipbuf space but that will change.
      Repeated calls without characters being added are not cumulative.  (ie if you
      call it with 1, 1, 1, and then 4 you'll have four characters of space.  The
      other functions will also try and grow buffers in future but this will be a
      more efficient way when you know block sizes.
      
       int tty_insert_flip_char(tty, ch, flag)
      
      As before insert a character if there is room.  Now returns 1 for success, 0
      for failure.
      
       int tty_insert_flip_string(tty, str, len)
      
      Insert a block of non error characters.  Returns the number inserted.
      
       int tty_prepare_flip_string(tty, strptr, len)
      
      Adjust the buffer to allow len characters to be added.  Returns a buffer
      pointer in strptr and the length available.  This allows for hardware that
      needs to use functions like insl or mencpy_fromio.
      Signed-off-by: NAlan Cox <alan@redhat.com>
      Cc: Paul Fulghum <paulkf@microgate.com>
      Signed-off-by: NHirokazu Takata <takata@linux-m32r.org>
      Signed-off-by: NSerge Hallyn <serue@us.ibm.com>
      Signed-off-by: NJeff Dike <jdike@addtoit.com>
      Signed-off-by: NJohn Hawkes <hawkes@sgi.com>
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: NAdrian Bunk <bunk@stusta.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      33f0f88f
  18. 09 1月, 2006 1 次提交
  19. 10 9月, 2005 1 次提交
  20. 24 6月, 2005 1 次提交
  21. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4