1. 17 10月, 2012 1 次提交
    • A
      fix a leak in replace_fd() users · 45525b26
      Al Viro 提交于
      replace_fd() began with "eats a reference, tries to insert into
      descriptor table" semantics; at some point I'd switched it to
      much saner current behaviour ("try to insert into descriptor
      table, grabbing a new reference if inserted; caller should do
      fput() in any case"), but forgot to update the callers.
      Mea culpa...
      
      [Spotted by Pavel Roskin, who has really weird system with pipe-fed
      coredumps as part of what he considers a normal boot ;-)]
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      45525b26
  2. 12 10月, 2012 1 次提交
  3. 27 9月, 2012 3 次提交
  4. 31 7月, 2012 1 次提交
  5. 30 7月, 2012 1 次提交
    • A
      selinux: fix selinux_inode_setxattr oops · e3fea3f7
      Al Viro 提交于
      OK, what we have so far is e.g.
      	setxattr(path, name, whatever, 0, XATTR_REPLACE)
      with name being good enough to get through xattr_permission().
      Then we reach security_inode_setxattr() with the desired value and size.
      Aha.  name should begin with "security.selinux", or we won't get that
      far in selinux_inode_setxattr().  Suppose we got there and have enough
      permissions to relabel that sucker.  We call security_context_to_sid()
      with value == NULL, size == 0.  OK, we want ss_initialized to be non-zero.
      I.e. after everything had been set up and running.  No problem...
      
      We do 1-byte kmalloc(), zero-length memcpy() (which doesn't oops, even
      thought the source is NULL) and put a NUL there.  I.e. form an empty
      string.  string_to_context_struct() is called and looks for the first
      ':' in there.  Not found, -EINVAL we get.  OK, security_context_to_sid_core()
      has rc == -EINVAL, force == 0, so it silently returns -EINVAL.
      All it takes now is not having CAP_MAC_ADMIN and we are fucked.
      
      All right, it might be a different bug (modulo strange code quoted in the
      report), but it's real.  Easily fixed, AFAICS:
      
      Deal with size == 0, value == NULL case in selinux_inode_setxattr()
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: NDave Jones <davej@redhat.com>
      Reported-by: NDave Jones <davej@redhat.com>
      Signed-off-by: NJames Morris <james.l.morris@oracle.com>
      e3fea3f7
  6. 27 7月, 2012 1 次提交
    • J
      posix_types.h: Cleanup stale __NFDBITS and related definitions · 8ded2bbc
      Josh Boyer 提交于
      Recently, glibc made a change to suppress sign-conversion warnings in
      FD_SET (glibc commit ceb9e56b3d1).  This uncovered an issue with the
      kernel's definition of __NFDBITS if applications #include
      <linux/types.h> after including <sys/select.h>.  A build failure would
      be seen when passing the -Werror=sign-compare and -D_FORTIFY_SOURCE=2
      flags to gcc.
      
      It was suggested that the kernel should either match the glibc
      definition of __NFDBITS or remove that entirely.  The current in-kernel
      uses of __NFDBITS can be replaced with BITS_PER_LONG, and there are no
      uses of the related __FDELT and __FDMASK defines.  Given that, we'll
      continue the cleanup that was started with commit 8b3d1cda
      ("posix_types: Remove fd_set macros") and drop the remaining unused
      macros.
      
      Additionally, linux/time.h has similar macros defined that expand to
      nothing so we'll remove those at the same time.
      Reported-by: NJeff Law <law@redhat.com>
      Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NJosh Boyer <jwboyer@redhat.com>
      [ .. and fix up whitespace as per akpm ]
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8ded2bbc
  7. 23 7月, 2012 1 次提交
  8. 16 7月, 2012 1 次提交
  9. 07 6月, 2012 1 次提交
  10. 01 6月, 2012 2 次提交
  11. 14 4月, 2012 1 次提交
    • A
      Add PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs · 259e5e6c
      Andy Lutomirski 提交于
      With this change, calling
        prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)
      disables privilege granting operations at execve-time.  For example, a
      process will not be able to execute a setuid binary to change their uid
      or gid if this bit is set.  The same is true for file capabilities.
      
      Additionally, LSM_UNSAFE_NO_NEW_PRIVS is defined to ensure that
      LSMs respect the requested behavior.
      
      To determine if the NO_NEW_PRIVS bit is set, a task may call
        prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0);
      It returns 1 if set and 0 if it is not set. If any of the arguments are
      non-zero, it will return -1 and set errno to -EINVAL.
      (PR_SET_NO_NEW_PRIVS behaves similarly.)
      
      This functionality is desired for the proposed seccomp filter patch
      series.  By using PR_SET_NO_NEW_PRIVS, it allows a task to modify the
      system call behavior for itself and its child tasks without being
      able to impact the behavior of a more privileged task.
      
      Another potential use is making certain privileged operations
      unprivileged.  For example, chroot may be considered "safe" if it cannot
      affect privileged tasks.
      
      Note, this patch causes execve to fail when PR_SET_NO_NEW_PRIVS is
      set and AppArmor is in use.  It is fixed in a subsequent patch.
      Signed-off-by: NAndy Lutomirski <luto@amacapital.net>
      Signed-off-by: NWill Drewry <wad@chromium.org>
      Acked-by: NEric Paris <eparis@redhat.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      
      v18: updated change desc
      v17: using new define values as per 3.4
      Signed-off-by: NJames Morris <james.l.morris@oracle.com>
      259e5e6c
  12. 10 4月, 2012 11 次提交
    • E
      SELinux: remove unused common_audit_data in flush_unauthorized_files · c737f828
      Eric Paris 提交于
      We don't need this variable and it just eats stack space.  Remove it.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      c737f828
    • E
      SELinux: unify the selinux_audit_data and selinux_late_audit_data · 899838b2
      Eric Paris 提交于
      We no longer need the distinction.  We only need data after we decide to do an
      audit.  So turn the "late" audit data into just "data" and remove what we
      currently have as "data".
      Signed-off-by: NEric Paris <eparis@redhat.com>
      899838b2
    • E
      LSM: do not initialize common_audit_data to 0 · 50c205f5
      Eric Paris 提交于
      It isn't needed.  If you don't set the type of the data associated with
      that type it is a pretty obvious programming bug.  So why waste the cycles?
      Signed-off-by: NEric Paris <eparis@redhat.com>
      50c205f5
    • E
      LSM: remove the task field from common_audit_data · b466066f
      Eric Paris 提交于
      There are no legitimate users.  Always use current and get back some stack
      space for the common_audit_data.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      b466066f
    • E
      LSM: remove the COMMON_AUDIT_DATA_INIT type expansion · bd5e50f9
      Eric Paris 提交于
      Just open code it so grep on the source code works better.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      bd5e50f9
    • E
      SELinux: move common_audit_data to a noinline slow path function · d4cf970d
      Eric Paris 提交于
      selinux_inode_has_perm is a hot path.  Instead of declaring the
      common_audit_data on the stack move it to a noinline function only used in
      the rare case we need to send an audit message.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      d4cf970d
    • E
      SELinux: remove inode_has_perm_noadp · 602a8dd6
      Eric Paris 提交于
      Both callers could better be using file_has_perm() to get better audit
      results.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      602a8dd6
    • E
      SELinux: delay initialization of audit data in selinux_inode_permission · 2e334057
      Eric Paris 提交于
      We pay a rather large overhead initializing the common_audit_data.
      Since we only need this information if we actually emit an audit
      message there is little need to set it up in the hot path.  This patch
      splits the functionality of avc_has_perm() into avc_has_perm_noaudit(),
      avc_audit_required() and slow_avc_audit().  But we take care of setting
      up to audit between required() and the actual audit call.  Thus saving
      measurable time in a hot path.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      2e334057
    • E
      SELinux: audit failed attempts to set invalid labels · d6ea83ec
      Eric Paris 提交于
      We know that some yum operation is causing CAP_MAC_ADMIN failures.  This
      implies that an RPM is laying down (or attempting to lay down) a file with
      an invalid label.  The problem is that we don't have any information to
      track down the cause.  This patch will cause such a failure to report the
      failed label in an SELINUX_ERR audit message.  This is similar to the
      SELINUX_ERR reports on invalid transitions and things like that.  It should
      help run down problems on what is trying to set invalid labels in the
      future.
      
      Resulting records look something like:
      type=AVC msg=audit(1319659241.138:71): avc:  denied  { mac_admin } for pid=2594 comm="chcon" capability=33 scontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=capability2
      type=SELINUX_ERR msg=audit(1319659241.138:71): op=setxattr invalid_context=unconfined_u:object_r:hello:s0
      type=SYSCALL msg=audit(1319659241.138:71): arch=c000003e syscall=188 success=no exit=-22 a0=a2c0e0 a1=390341b79b a2=a2d620 a3=1f items=1 ppid=2519 pid=2594 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="chcon" exe="/usr/bin/chcon" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
      type=CWD msg=audit(1319659241.138:71):  cwd="/root" type=PATH msg=audit(1319659241.138:71): item=0 name="test" inode=785879 dev=fc:03 mode=0100644 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:admin_home_t:s0
      Signed-off-by: NEric Paris <eparis@redhat.com>
      d6ea83ec
    • E
      SELinux: rename dentry_open to file_open · 83d49856
      Eric Paris 提交于
      dentry_open takes a file, rename it to file_open
      Signed-off-by: NEric Paris <eparis@redhat.com>
      83d49856
    • E
      SELinux: check OPEN on truncate calls · 95dbf739
      Eric Paris 提交于
      In RH BZ 578841 we realized that the SELinux sandbox program was allowed to
      truncate files outside of the sandbox.  The reason is because sandbox
      confinement is determined almost entirely by the 'open' permission.  The idea
      was that if the sandbox was unable to open() files it would be unable to do
      harm to those files.  This turns out to be false in light of syscalls like
      truncate() and chmod() which don't require a previous open() call.  I looked
      at the syscalls that did not have an associated 'open' check and found that
      truncate(), did not have a seperate permission and even if it did have a
      separate permission such a permission owuld be inadequate for use by
      sandbox (since it owuld have to be granted so liberally as to be useless).
      This patch checks the OPEN permission on truncate.  I think a better solution
      for sandbox is a whole new permission, but at least this fixes what we have
      today.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      95dbf739
  13. 04 4月, 2012 2 次提交
    • E
      LSM: shrink the common_audit_data data union · 48c62af6
      Eric Paris 提交于
      After shrinking the common_audit_data stack usage for private LSM data I'm
      not going to shrink the data union.  To do this I'm going to move anything
      larger than 2 void * ptrs to it's own structure and require it to be declared
      separately on the calling stack.  Thus hot paths which don't need more than
      a couple pointer don't have to declare space to hold large unneeded
      structures.  I could get this down to one void * by dealing with the key
      struct and the struct path.  We'll see if that is helpful after taking care of
      networking.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      48c62af6
    • E
      LSM: shrink sizeof LSM specific portion of common_audit_data · 3b3b0e4f
      Eric Paris 提交于
      Linus found that the gigantic size of the common audit data caused a big
      perf hit on something as simple as running stat() in a loop.  This patch
      requires LSMs to declare the LSM specific portion separately rather than
      doing it in a union.  Thus each LSM can be responsible for shrinking their
      portion and don't have to pay a penalty just because other LSMs have a
      bigger space requirement.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3b3b0e4f
  14. 01 4月, 2012 1 次提交
  15. 20 2月, 2012 1 次提交
    • D
      Replace the fd_sets in struct fdtable with an array of unsigned longs · 1fd36adc
      David Howells 提交于
      Replace the fd_sets in struct fdtable with an array of unsigned longs and then
      use the standard non-atomic bit operations rather than the FD_* macros.
      
      This:
      
       (1) Removes the abuses of struct fd_set:
      
           (a) Since we don't want to allocate a full fd_set the vast majority of the
           	 time, we actually, in effect, just allocate a just-big-enough array of
           	 unsigned longs and cast it to an fd_set type - so why bother with the
           	 fd_set at all?
      
           (b) Some places outside of the core fdtable handling code (such as
           	 SELinux) want to look inside the array of unsigned longs hidden inside
           	 the fd_set struct for more efficient iteration over the entire set.
      
       (2) Eliminates the use of FD_*() macros in the kernel completely.
      
       (3) Permits the __FD_*() macros to be deleted entirely where not exposed to
           userspace.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Link: http://lkml.kernel.org/r/20120216174954.23314.48147.stgit@warthog.procyon.org.ukSigned-off-by: NH. Peter Anvin <hpa@zytor.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      1fd36adc
  16. 14 2月, 2012 1 次提交
  17. 07 1月, 2012 1 次提交
  18. 06 1月, 2012 7 次提交
  19. 04 1月, 2012 2 次提交