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. 01 12月, 2010 4 次提交
  5. 21 10月, 2010 5 次提交
    • 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
      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: 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
  6. 02 8月, 2010 1 次提交
    • E
      selinux: convert the policy type_attr_map to flex_array · 6371dcd3
      Eric Paris 提交于
      Current selinux policy can have over 3000 types.  The type_attr_map in
      policy is an array sized by the number of types times sizeof(struct ebitmap)
      (12 on x86_64).  Basic math tells us the array is going to be of length
      3000 x 12 = 36,000 bytes.  The largest 'safe' allocation on a long running
      system is 16k.  Most of the time a 32k allocation will work.  But on long
      running systems a 64k allocation (what we need) can fail quite regularly.
      In order to deal with this I am converting the type_attr_map to use
      flex_arrays.  Let the library code deal with breaking this into PAGE_SIZE
      pieces.
      
      -v2
      rework some of the if(!obj) BUG() to be BUG_ON(!obj)
      drop flex_array_put() calls and just use a _get() object directly
      
      -v3
      make apply to James' tree (drop the policydb_write changes)
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Acked-by: NStephen D. Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      6371dcd3
  7. 21 4月, 2010 1 次提交
  8. 09 4月, 2010 1 次提交
  9. 22 2月, 2010 1 次提交
  10. 16 2月, 2010 1 次提交
  11. 04 2月, 2010 2 次提交
  12. 25 1月, 2010 1 次提交
    • K
      selinux: remove dead code in type_attribute_bounds_av() · 7d52a155
      KaiGai Kohei 提交于
      This patch removes dead code in type_attribute_bounds_av().
      
      Due to the historical reason, the type boundary feature is delivered
      from hierarchical types in libsepol, it has supported boundary features
      both of subject type (domain; in most cases) and target type.
      
      However, we don't have any actual use cases in bounded target types,
      and it tended to make conceptual confusion.
      So, this patch removes the dead code to apply boundary checks on the
      target types. I makes clear the TYPEBOUNDS restricts privileges of
      a certain domain bounded to any other domain.
      Signed-off-by: NKaiGai Kohei <kaigai@ak.jp.nec.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      
      --
       security/selinux/ss/services.c |   43 +++------------------------------------
       1 files changed, 4 insertions(+), 39 deletions(-)
      Signed-off-by: NJames Morris <jmorris@namei.org>
      7d52a155
  13. 18 1月, 2010 1 次提交
    • S
      selinux: change the handling of unknown classes · 19439d05
      Stephen Smalley 提交于
      If allow_unknown==deny, SELinux treats an undefined kernel security
      class as an error condition rather than as a typical permission denial
      and thus does not allow permissions on undefined classes even when in
      permissive mode.  Change the SELinux logic so that this case is handled
      as a typical permission denial, subject to the usual permissive mode and
      permissive domain handling.
      
      Also drop the 'requested' argument from security_compute_av() and
      helpers as it is a legacy of the original security server interface and
      is unused.
      
      Changes:
      - Handle permissive domains consistently by moving up the test for a
      permissive domain.
      - Make security_compute_av_user() consistent with security_compute_av();
      the only difference now is that security_compute_av() performs mapping
      between the kernel-private class and permission indices and the policy
      values.  In the userspace case, this mapping is handled by libselinux.
      - Moved avd_init inside the policy lock.
      
      Based in part on a patch by Paul Moore <paul.moore@hp.com>.
      Reported-by: NAndrew Worsley <amworsley@gmail.com>
      Signed-off-by: NStephen D. Smalley <sds@tycho.nsa.gov>
      Reviewed-by: NPaul Moore <paul.moore@hp.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      19439d05
  14. 08 12月, 2009 1 次提交
  15. 04 12月, 2009 1 次提交
  16. 24 11月, 2009 1 次提交
    • E
      SELinux: print denials for buggy kernel with unknown perms · 0bce9527
      Eric Paris 提交于
      Historically we've seen cases where permissions are requested for classes
      where they do not exist.  In particular we have seen CIFS forget to set
      i_mode to indicate it is a directory so when we later check something like
      remove_name we have problems since it wasn't defined in tclass file.  This
      used to result in a avc which included the permission 0x2000 or something.
      Currently the kernel will deny the operations (good thing) but will not
      print ANY information (bad thing).  First the auditdeny field is no
      extended to include unknown permissions.  After that is fixed the logic in
      avc_dump_query to output this information isn't right since it will remove
      the permission from the av and print the phrase "<NULL>".  This takes us
      back to the behavior before the classmap rewrite.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      0bce9527
  17. 20 10月, 2009 1 次提交
  18. 07 10月, 2009 2 次提交
    • S
      selinux: drop remapping of netlink classes · 941fc5b2
      Stephen Smalley 提交于
      Drop remapping of netlink classes and bypass of permission checking
      based on netlink message type for policy version < 18.  This removes
      compatibility code introduced when the original single netlink
      security class used for all netlink sockets was split into
      finer-grained netlink classes based on netlink protocol and when
      permission checking was added based on netlink message type in Linux
      2.6.8.  The only known distribution that shipped with SELinux and
      policy < 18 was Fedora Core 2, which was EOL'd on 2005-04-11.
      
      Given that the remapping code was never updated to address the
      addition of newer netlink classes, that the corresponding userland
      support was dropped in 2005, and that the assumptions made by the
      remapping code about the fixed ordering among netlink classes in the
      policy may be violated in the future due to the dynamic class/perm
      discovery support, we should drop this compatibility code now.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      941fc5b2
    • S
      selinux: dynamic class/perm discovery · c6d3aaa4
      Stephen Smalley 提交于
      Modify SELinux to dynamically discover class and permission values
      upon policy load, based on the dynamic object class/perm discovery
      logic from libselinux.  A mapping is created between kernel-private
      class and permission indices used outside the security server and the
      policy values used within the security server.
      
      The mappings are only applied upon kernel-internal computations;
      similar mappings for the private indices of userspace object managers
      is handled on a per-object manager basis by the userspace AVC.  The
      interfaces for compute_av and transition_sid are split for kernel
      vs. userspace; the userspace functions are distinguished by a _user
      suffix.
      
      The kernel-private class indices are no longer tied to the policy
      values and thus do not need to skip indices for userspace classes;
      thus the kernel class index values are compressed.  The flask.h
      definitions were regenerated by deleting the userspace classes from
      refpolicy's definitions and then regenerating the headers.  Going
      forward, we can just maintain the flask.h, av_permissions.h, and
      classmap.h definitions separately from policy as they are no longer
      tied to the policy values.  The next patch introduces a utility to
      automate generation of flask.h and av_permissions.h from the
      classmap.h definitions.
      
      The older kernel class and permission string tables are removed and
      replaced by a single security class mapping table that is walked at
      policy load to generate the mapping.  The old kernel class validation
      logic is completely replaced by the mapping logic.
      
      The handle unknown logic is reworked.  reject_unknown=1 is handled
      when the mappings are computed at policy load time, similar to the old
      handling by the class validation logic.  allow_unknown=1 is handled
      when computing and mapping decisions - if the permission was not able
      to be mapped (i.e. undefined, mapped to zero), then it is
      automatically added to the allowed vector.  If the class was not able
      to be mapped (i.e. undefined, mapped to zero), then all permissions
      are allowed for it if allow_unknown=1.
      
      avc_audit leverages the new security class mapping table to lookup the
      class and permission names from the kernel-private indices.
      
      The mdp program is updated to use the new table when generating the
      class definitions and allow rules for a minimal boot policy for the
      kernel.  It should be noted that this policy will not include any
      userspace classes, nor will its policy index values for the kernel
      classes correspond with the ones in refpolicy (they will instead match
      the kernel-private indices).
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      c6d3aaa4
  19. 18 6月, 2009 2 次提交
    • K
      Add audit messages on type boundary violations · 44c2d9bd
      KaiGai Kohei 提交于
      The attached patch adds support to generate audit messages on two cases.
      
      The first one is a case when a multi-thread process tries to switch its
      performing security context using setcon(3), but new security context is
      not bounded by the old one.
      
        type=SELINUX_ERR msg=audit(1245311998.599:17):        \
            op=security_bounded_transition result=denied      \
            oldcontext=system_u:system_r:httpd_t:s0           \
            newcontext=system_u:system_r:guest_webapp_t:s0
      
      The other one is a case when security_compute_av() masked any permissions
      due to the type boundary violation.
      
        type=SELINUX_ERR msg=audit(1245312836.035:32):	\
            op=security_compute_av reason=bounds              \
            scontext=system_u:object_r:user_webapp_t:s0       \
            tcontext=system_u:object_r:shadow_t:s0:c0         \
            tclass=file perms=getattr,open
      Signed-off-by: NKaiGai Kohei <kaigai@ak.jp.nec.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      44c2d9bd
    • K
      cleanup in ss/services.c · caabbdc0
      KaiGai Kohei 提交于
      It is a cleanup patch to cut down a line within 80 columns.
      Signed-off-by: NKaiGai Kohei <kaigai@ak.jp.nec.com>
      --
       security/selinux/ss/services.c |    6 +++---
       1 files changed, 3 insertions(+), 3 deletions(-)
      Signed-off-by: NJames Morris <jmorris@namei.org>
      caabbdc0
  20. 02 4月, 2009 1 次提交
    • K
      Permissive domain in userspace object manager · 8a6f83af
      KaiGai Kohei 提交于
      This patch enables applications to handle permissive domain correctly.
      
      Since the v2.6.26 kernel, SELinux has supported an idea of permissive
      domain which allows certain processes to work as if permissive mode,
      even if the global setting is enforcing mode.
      However, we don't have an application program interface to inform
      what domains are permissive one, and what domains are not.
      It means applications focuses on SELinux (XACE/SELinux, SE-PostgreSQL
      and so on) cannot handle permissive domain correctly.
      
      This patch add the sixth field (flags) on the reply of the /selinux/access
      interface which is used to make an access control decision from userspace.
      If the first bit of the flags field is positive, it means the required
      access control decision is on permissive domain, so application should
      allow any required actions, as the kernel doing.
      
      This patch also has a side benefit. The av_decision.flags is set at
      context_struct_compute_av(). It enables to check required permissions
      without read_lock(&policy_rwlock).
      Signed-off-by: NKaiGai Kohei <kaigai@ak.jp.nec.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Acked-by: NEric Paris <eparis@redhat.com>
      --
       security/selinux/avc.c              |    2 +-
       security/selinux/include/security.h |    4 +++-
       security/selinux/selinuxfs.c        |    4 ++--
       security/selinux/ss/services.c      |   30 +++++-------------------------
       4 files changed, 11 insertions(+), 29 deletions(-)
      Signed-off-by: NJames Morris <jmorris@namei.org>
      8a6f83af
  21. 14 2月, 2009 1 次提交
  22. 05 1月, 2009 1 次提交
  23. 10 10月, 2008 2 次提交
  24. 04 10月, 2008 2 次提交
    • P
      selinux: Fix an uninitialized variable BUG/panic in selinux_secattr_to_sid() · 3040a6d5
      Paul Moore 提交于
      At some point during the 2.6.27 development cycle two new fields were added
      to the SELinux context structure, a string pointer and a length field.  The
      code in selinux_secattr_to_sid() was not modified and as a result these two
      fields were left uninitialized which could result in erratic behavior,
      including kernel panics, when NetLabel is used.  This patch fixes the
      problem by fully initializing the context in selinux_secattr_to_sid() before
      use and reducing the level of direct context manipulation done to help
      prevent future problems.
      
      Please apply this to the 2.6.27-rcX release stream.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      3040a6d5
    • P
      selinux: Fix an uninitialized variable BUG/panic in selinux_secattr_to_sid() · 81990fbd
      Paul Moore 提交于
      At some point during the 2.6.27 development cycle two new fields were added
      to the SELinux context structure, a string pointer and a length field.  The
      code in selinux_secattr_to_sid() was not modified and as a result these two
      fields were left uninitialized which could result in erratic behavior,
      including kernel panics, when NetLabel is used.  This patch fixes the
      problem by fully initializing the context in selinux_secattr_to_sid() before
      use and reducing the level of direct context manipulation done to help
      prevent future problems.
      
      Please apply this to the 2.6.27-rcX release stream.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      81990fbd
  25. 04 9月, 2008 1 次提交
  26. 28 8月, 2008 1 次提交
    • K
      SELinux: add boundary support and thread context assignment · d9250dea
      KaiGai Kohei 提交于
      The purpose of this patch is to assign per-thread security context
      under a constraint. It enables multi-threaded server application
      to kick a request handler with its fair security context, and
      helps some of userspace object managers to handle user's request.
      
      When we assign a per-thread security context, it must not have wider
      permissions than the original one. Because a multi-threaded process
      shares a single local memory, an arbitary per-thread security context
      also means another thread can easily refer violated information.
      
      The constraint on a per-thread security context requires a new domain
      has to be equal or weaker than its original one, when it tries to assign
      a per-thread security context.
      
      Bounds relationship between two types is a way to ensure a domain can
      never have wider permission than its bounds. We can define it in two
      explicit or implicit ways.
      
      The first way is using new TYPEBOUNDS statement. It enables to define
      a boundary of types explicitly. The other one expand the concept of
      existing named based hierarchy. If we defines a type with "." separated
      name like "httpd_t.php", toolchain implicitly set its bounds on "httpd_t".
      
      This feature requires a new policy version.
      The 24th version (POLICYDB_VERSION_BOUNDARY) enables to ship them into
      kernel space, and the following patch enables to handle it.
      Signed-off-by: NKaiGai Kohei <kaigai@ak.jp.nec.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      d9250dea
  27. 15 8月, 2008 1 次提交
  28. 15 7月, 2008 1 次提交