1. 29 3月, 2011 1 次提交
  2. 04 3月, 2011 1 次提交
  3. 02 2月, 2011 1 次提交
    • E
      SELinux: Use dentry name in new object labeling · 652bb9b0
      Eric Paris 提交于
      Currently SELinux has rules which label new objects according to 3 criteria.
      The label of the process creating the object, the label of the parent
      directory, and the type of object (reg, dir, char, block, etc.)  This patch
      adds a 4th criteria, the dentry name, thus we can distinguish between
      creating a file in an etc_t directory called shadow and one called motd.
      
      There is no file globbing, regex parsing, or anything mystical.  Either the
      policy exactly (strcmp) matches the dentry name of the object or it doesn't.
      This patch has no changes from today if policy does not implement the new
      rules.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      652bb9b0
  4. 24 1月, 2011 2 次提交
  5. 08 12月, 2010 1 次提交
    • E
      selinux: cache sidtab_context_to_sid results · 73ff5fc0
      Eric Paris 提交于
      sidtab_context_to_sid takes up a large share of time when creating large
      numbers of new inodes (~30-40% in oprofile runs).  This patch implements a
      cache of 3 entries which is checked before we do a full context_to_sid lookup.
      On one system this showed over a x3 improvement in the number of inodes that
      could be created per second and around a 20% improvement on another system.
      
      Any time we look up the same context string sucessivly (imagine ls -lZ) we
      should hit this cache hot.  A cache miss should have a relatively minor affect
      on performance next to doing the full table search.
      
      All operations on the cache are done COMPLETELY lockless.  We know that all
      struct sidtab_node objects created will never be deleted until a new policy is
      loaded thus we never have to worry about a pointer being dereferenced.  Since
      we also know that pointer assignment is atomic we know that the cache will
      always have valid pointers.  Given this information we implement a FIFO cache
      in an array of 3 pointers.  Every result (whether a cache hit or table lookup)
      will be places in the 0 spot of the cache and the rest of the entries moved
      down one spot.  The 3rd entry will be lost.
      
      Races are possible and are even likely to happen.  Lets assume that 4 tasks
      are hitting sidtab_context_to_sid.  The first task checks against the first
      entry in the cache and it is a miss.  Now lets assume a second task updates
      the cache with a new entry.  This will push the first entry back to the second
      spot.  Now the first task might check against the second entry (which it
      already checked) and will miss again.  Now say some third task updates the
      cache and push the second entry to the third spot.  The first task my check
      the third entry (for the third time!) and again have a miss.  At which point
      it will just do a full table lookup.  No big deal!
      Signed-off-by: NEric Paris <eparis@redhat.com>
      73ff5fc0
  6. 01 12月, 2010 6 次提交
  7. 21 10月, 2010 10 次提交
    • S
      selinux: include vmalloc.h for vmalloc_user · f0d3d989
      Stephen Rothwell 提交于
      Include vmalloc.h for vmalloc_user (fixes ppc build warning).
      Acked-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      f0d3d989
    • E
      selinux: implement mmap on /selinux/policy · 845ca30f
      Eric Paris 提交于
      /selinux/policy allows a user to copy the policy back out of the kernel.
      This patch allows userspace to actually mmap that file and use it directly.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      845ca30f
    • E
      SELinux: allow userspace to read policy back out of the kernel · cee74f47
      Eric Paris 提交于
      There is interest in being able to see what the actual policy is that was
      loaded into the kernel.  The patch creates a new selinuxfs file
      /selinux/policy which can be read by userspace.  The actual policy that is
      loaded into the kernel will be written back out to userspace.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      cee74f47
    • E
      SELinux: drop useless (and incorrect) AVTAB_MAX_SIZE · 00d85c83
      Eric Paris 提交于
      AVTAB_MAX_SIZE was a define which was supposed to be used in userspace to
      define a maximally sized avtab when userspace wasn't sure how big of a table
      it needed.  It doesn't make sense in the kernel since we always know our table
      sizes.  The only place it is used we have a more appropiately named define
      called AVTAB_MAX_HASH_BUCKETS, use that instead.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      00d85c83
    • E
      SELinux: deterministic ordering of range transition rules · 4419aae1
      Eric Paris 提交于
      Range transition rules are placed in the hash table in an (almost)
      arbitrary order.  This patch inserts them in a fixed order to make policy
      retrival more predictable.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      4419aae1
    • E
      security: secid_to_secctx returns len when data is NULL · d5630b9d
      Eric Paris 提交于
      With the (long ago) interface change to have the secid_to_secctx functions
      do the string allocation instead of having the caller do the allocation we
      lost the ability to query the security server for the length of the
      upcoming string.  The SECMARK code would like to allocate a netlink skb
      with enough length to hold the string but it is just too unclean to do the
      string allocation twice or to do the allocation the first time and hold
      onto the string and slen.  This patch adds the ability to call
      security_secid_to_secctx() with a NULL data pointer and it will just set
      the slen pointer.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Reviewed-by: NPaul Moore <paul.moore@hp.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      d5630b9d
    • K
      selinux: fix up style problem on /selinux/status · 36f7f284
      KaiGai Kohei 提交于
      This patch fixes up coding-style problem at this commit:
      
       4f27a7d49789b04404eca26ccde5f527231d01d5
       selinux: fast status update interface (/selinux/status)
      Signed-off-by: NKaiGai Kohei <kaigai@ak.jp.nec.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      36f7f284
    • P
      selinux: really fix dependency causing parallel compile failure. · 60272da0
      Paul Gortmaker 提交于
      While the previous change to the selinux Makefile reduced the window
      significantly for this failure, it is still possible to see a compile
      failure where cpp starts processing selinux files before the auto
      generated flask.h file is completed.  This is easily reproduced by
      adding the following temporary change to expose the issue everytime:
      
      -      cmd_flask = scripts/selinux/genheaders/genheaders ...
      +      cmd_flask = sleep 30 ; scripts/selinux/genheaders/genheaders ...
      
      This failure happens because the creation of the object files in the ss
      subdir also depends on flask.h.  So simply incorporate them into the
      parent Makefile, as the ss/Makefile really doesn't do anything unique.
      
      With this change, compiling of all selinux files is dependent on
      completion of the header file generation, and this test case with
      the "sleep 30" now confirms it is functioning as expected.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      60272da0
    • K
      selinux: fast status update interface (/selinux/status) · 11904167
      KaiGai Kohei 提交于
      This patch provides a new /selinux/status entry which allows applications
      read-only mmap(2).
      This region reflects selinux_kernel_status structure in kernel space.
        struct selinux_kernel_status
        {
                u32     length;         /* length of this structure */
                u32     sequence;       /* sequence number of seqlock logic */
                u32     enforcing;      /* current setting of enforcing mode */
                u32     policyload;     /* times of policy reloaded */
                u32     deny_unknown;   /* current setting of deny_unknown */
        };
      
      When userspace object manager caches access control decisions provided
      by SELinux, it needs to invalidate the cache on policy reload and setenforce
      to keep consistency.
      However, the applications need to check the kernel state for each accesses
      on userspace avc, or launch a background worker process.
      In heuristic, frequency of invalidation is much less than frequency of
      making access control decision, so it is annoying to invoke a system call
      to check we don't need to invalidate the userspace cache.
      If we can use a background worker thread, it allows to receive invalidation
      messages from the kernel. But it requires us an invasive coding toward the
      base application in some cases; E.g, when we provide a feature performing
      with SELinux as a plugin module, it is unwelcome manner to launch its own
      worker thread from the module.
      
      If we could map /selinux/status to process memory space, application can
      know updates of selinux status; policy reload or setenforce.
      
      A typical application checks selinux_kernel_status::sequence when it tries
      to reference userspace avc. If it was changed from the last time when it
      checked userspace avc, it means something was updated in the kernel space.
      Then, the application can reset userspace avc or update current enforcing
      mode, without any system call invocations.
      This sequence number is updated according to the seqlock logic, so we need
      to wait for a while if it is odd number.
      Signed-off-by: NKaiGai Kohei <kaigai@ak.jp.nec.com>
      Acked-by: NEric Paris <eparis@redhat.com>
      --
       security/selinux/include/security.h |   21 ++++++
       security/selinux/selinuxfs.c        |   56 +++++++++++++++
       security/selinux/ss/Makefile        |    2 +-
       security/selinux/ss/services.c      |    3 +
       security/selinux/ss/status.c        |  129 +++++++++++++++++++++++++++++++++++
       5 files changed, 210 insertions(+), 1 deletions(-)
      Signed-off-by: NJames Morris <jmorris@namei.org>
      11904167
    • E
      selinux: type_bounds_sanity_check has a meaningless variable declaration · daa6d83a
      Eric Paris 提交于
      type is not used at all, stop declaring and assigning it.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      daa6d83a
  8. 02 8月, 2010 11 次提交
  9. 17 5月, 2010 1 次提交
  10. 21 4月, 2010 1 次提交
  11. 15 4月, 2010 1 次提交
  12. 09 4月, 2010 1 次提交
  13. 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
  14. 16 3月, 2010 1 次提交
  15. 08 3月, 2010 1 次提交