1. 28 Jan, 2016 6 commits
    • Peter Hurley's avatar
      tty: audit: Ignore current association for audit push · b50819f4
      Peter Hurley authored
      In canonical read mode, each line read and logged is pushed separately
      with tty_audit_push(). For all single-threaded processes and multi-threaded
      processes reading from only one tty, this patch has no effect; the last line
      read will still be the entry pushed to the audit log because the tty
      association cannot have changed between tty_audit_add_data() and
      tty_audit_push().
      
      For multi-threaded processes reading from different ttys concurrently,
      the audit log will have mixed log entries anyway. Consider two ttys
      audited concurrently:
      
      CPU0                           CPU1
      ----------                     ------------
      tty_audit_add_data(ttyA)
                                     tty_audit_add_data(ttyB)
      tty_audit_push()
                                     tty_audit_add_data(ttyB)
                                     tty_audit_push()
      
      This patch will now cause the ttyB output to be split into separate
      audit log entries.
      
      However, this possibility is equally likely without this patch:
      
      CPU0                           CPU1
      ----------                     ------------
                                     tty_audit_add_data(ttyB)
      tty_audit_add_data(ttyA)
      tty_audit_push()
                                     tty_audit_add_data(ttyB)
                                     tty_audit_push()
      
      Mixed canonical and non-canonical reads have similar races.
      Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b50819f4
    • Peter Hurley's avatar
      tty: audit: Take siglock directly · f229c2c1
      Peter Hurley authored
      lock_task_sighand() is for situations where the struct task_struct*
      may disappear while trying to deref the sighand; this never applies
      to 'current'.
      Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f229c2c1
    • Peter Hurley's avatar
      tty: audit: Defer audit buffer association · a75c9b09
      Peter Hurley authored
      The tty audit buffer used to audit/record tty input is allocated on
      the process's first call to tty_audit_add_data(), and not freed until
      the process exits. On each call to tty_audit_add_data(), the current
      tty is compared (by major:minor) with the last tty associated with
      the audit buffer, and if the tty has changed the existing data is
      logged to the audit log. The audit buffer is then re-associated with
      the new tty.
      
      Currently, the audit buffer is immediately associated with the tty;
      however, the association must be re-checked when the buffer is locked
      prior to copying the tty input. This extra step is always necessary,
      since a concurrent read of a different tty by another thread of the
      process may have used the buffer in between allocation and buffer
      lock.
      
      Rather than associate the audit buffer with the tty at allocation,
      leave the buffer initially un-associated (null dev_t); simply let the
      re-association check also perform the initial association.
      Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a75c9b09
    • Peter Hurley's avatar
      tty: audit: Remove icanon mode from call chain · 309426ae
      Peter Hurley authored
      The tty termios bits cannot change while n_tty_read() is in the
      i/o loop; the termios_rwsem ensures mutual exclusion with termios
      changes in n_tty_set_termios(). Check L_ICANON() directly and
      eliminate icanon parameter.
      
      NB: tty_audit_add_data() => tty_audit_buf_get() => tty_audit_buf_alloc()
      is a single path; ie., tty_audit_buf_get() and tty_audit_buf_alloc()
      have no other callers.
      Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      309426ae
    • Peter Hurley's avatar
      tty: audit: Never audit packet mode · eab25a5c
      Peter Hurley authored
      tty audit never logs pty master reads, but packet mode only works for
      pty masters, so tty_audit_add_data() was never logging packet mode
      anyway.
      
      Don't audit packet mode data. As those are the lone call sites, remove
      tty_put_user().
      Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eab25a5c
    • Peter Hurley's avatar
      tty: audit: Early-out pty master reads earlier · d7c0ba40
      Peter Hurley authored
      Reads from pty masters are not logged; early-out before taking
      locks.
      Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7c0ba40
  2. 27 Jan, 2016 34 commits