10 Sep, 2011

1 commit


02 Aug, 2011

1 commit


15 Jun, 2011

1 commit


29 Apr, 2011

5 commits

  • Change flex_array_prealloc to take the number of elements for which space
    should be allocated instead of the last (inclusive) element. Users
    and documentation are updated accordingly. flex_arrays got introduced before
    they had users. When folks started using it, they ended up needing a
    different API than was coded up originally. This swaps over to the API that
    folks apparently need.

    Based-on-patch-by: Steffen Klassert
    Signed-off-by: Eric Paris
    Tested-by: Chris Richards
    Acked-by: Dave Hansen
    Cc: stable@kernel.org [2.6.38+]

    Eric Paris
     
  • To shorten the list we need to run if filename trans rules exist for the type
    of the given parent directory I put them in a hashtable. Given the policy we
    are expecting to use in Fedora this takes the worst case list run from about
    5,000 entries to 17.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • Instead of a hashtab entry counter function only useful for range
    transition rules make a function generic for any hashtable to use.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • We have custom debug functions like rangetr_hash_eval and symtab_hash_eval
    which do the same thing. Just create a generic function that takes the name
    of the hash table as an argument instead of having custom functions.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • Right now we walk to filename trans rule list for every inode that is
    created. First passes at policy using this facility creates around 5000
    filename trans rules. Running a list of 5000 entries every time is a bad
    idea. This patch adds a new ebitmap to policy which has a bit set for each
    ttype that has at least 1 filename trans rule. Thus when an inode is
    created we can quickly determine if any rules exist for this parent
    directory type and can skip the list if we know there is definitely no
    relevant entry.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     

20 Apr, 2011

1 commit


08 Apr, 2011

1 commit


29 Mar, 2011

2 commits


08 Mar, 2011

1 commit


02 Feb, 2011

1 commit

  • 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: Eric Paris

    Eric Paris
     

24 Jan, 2011

1 commit


01 Dec, 2010

4 commits


21 Oct, 2010

3 commits


02 Aug, 2010

4 commits

  • 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: Eric Paris
    Acked-by: Stephen D. Smalley
    Signed-off-by: James Morris

    Eric Paris
     
  • Move the reading of ocontext type data out of policydb_read() in a separate
    function ocontext_read()

    Signed-off-by: Eric Paris
    Acked-by: Stephen D. Smalley
    Signed-off-by: James Morris

    Eric Paris
     
  • move genfs read functionality out of policydb_read() and into a new
    function called genfs_read()

    Signed-off-by: Eric Paris
    Acked-by: Stephen D. Smalley
    Signed-off-by: James Morris

    Eric Paris
     
  • Move the range transition rule to a separate function, range_read(), rather
    than doing it all in policydb_read()

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    Eric Paris
     

17 May, 2010

1 commit

  • Use kstrdup when the goal of an allocation is copy a string into the
    allocated region.

    The semantic patch that makes this change is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @@
    expression from,to;
    expression flag,E1,E2;
    statement S;
    @@

    - to = kmalloc(strlen(from) + 1,flag);
    + to = kstrdup(from, flag);
    ... when != \(from = E1 \| to = E1 \)
    if (to==NULL || ...) S
    ... when != \(from = E2 \| to = E2 \)
    - strcpy(to, from);
    //

    Signed-off-by: Julia Lawall
    Acked-by: Eric Paris
    Signed-off-by: James Morris

    Julia Lawall
     

09 Apr, 2010

1 commit


09 Mar, 2010

1 commit


08 Mar, 2010

1 commit


04 Feb, 2010

1 commit


25 Jan, 2010

1 commit

  • Per https://bugzilla.redhat.com/show_bug.cgi?id=548145
    there are sufficient range transition rules in modern (Fedora) policy to
    make mls_compute_sid a significant factor on the shmem file setup path
    due to the length of the range_tr list. Replace the simple range_tr
    list with a hashtab inside the security server to help mitigate this
    problem.

    Signed-off-by: Stephen D. Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     

07 Oct, 2009

1 commit

  • 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: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     

28 Aug, 2008

1 commit

  • 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: KaiGai Kohei
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    KaiGai Kohei
     

05 Aug, 2008

1 commit


14 Jul, 2008

1 commit

  • Fix an endianness bug in the handling of network node addresses by
    SELinux. This yields no change on little endian hardware but fixes
    the incorrect handling on big endian hardware. The network node
    addresses are stored in network order in memory by checkpolicy, not in
    cpu/host order, and thus should not have cpu_to_le32/le32_to_cpu
    conversions applied upon policy write/read unlike other data in the
    policy.

    Bug reported by John Weeks of Sun, who noticed that binary policy
    files built from the same policy source on x86 and sparc differed and
    tracked it down to the ipv4 address handling in checkpolicy.

    Signed-off-by: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     

21 Apr, 2008

2 commits

  • More formatting changes. Aside from the 80 character line limit even
    the checkpatch scripts like this file now. Too bad I don't get paid by
    the lines of code I change.

    Signed-off-by: Eric Paris
    Signed-off-by: James Morris

    Eric Paris
     
  • Make sure all printk start with KERN_*
    Make sure all printk end with \n
    Make sure all printk have the word 'selinux' in them
    Change "function name" to "%s", __func__ (found 2 wrong)

    Signed-off-by: Eric Paris
    Signed-off-by: James Morris

    Eric Paris
     

18 Apr, 2008

2 commits

  • Introduce the concept of a permissive type. A new ebitmap is introduced to
    the policy database which indicates if a given type has the permissive bit
    set or not. This bit is tested for the scontext of any denial. The bit is
    meaningless on types which only appear as the target of a decision and never
    the source. A domain running with a permissive type will be allowed to
    perform any action similarly to when the system is globally set permissive.

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    Eric Paris
     
  • Replace "security:" prefixes in printk messages with "SELinux"
    to help users identify the source of the messages. Also fix a
    couple of minor formatting issues.

    Signed-off-by: James Morris

    James Morris