10 Sep, 2011
1 commit
-
Fix several sparse warnings in the SELinux security server code.
Signed-off-by: James Morris
02 Aug, 2011
1 commit
-
My @hp.com will no longer be valid starting August 5, 2011 so an update is
necessary. My new email address is employer independent so we don't have
to worry about doing this again any time soon.Signed-off-by: Paul Moore
Signed-off-by: Paul Moore
Signed-off-by: David S. Miller
15 Jun, 2011
1 commit
-
When policy version is less than POLICYDB_VERSION_FILENAME_TRANS,
skip file_name_trans_write().Signed-off-by: Roy.Li
Signed-off-by: Eric Paris
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+] -
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 -
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 -
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 -
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
20 Apr, 2011
1 commit
-
The filename_trans rule processing has some printk(KERN_ERR ) messages
which were intended as debug aids in creating the code but weren't removed
before it was submitted. Remove them.Signed-off-by: Eric Paris
08 Apr, 2011
1 commit
-
Initialize policydb.process_class once all symtabs read from policy image,
so that it could be used to setup the role_trans.tclass field when a lower
version policy.X is loaded.Signed-off-by: Harry Ciao
Signed-off-by: Eric Paris
29 Mar, 2011
2 commits
-
If kernel policy version is >= 26, then write the class field of the
role_trans structure into the binary reprensentation.Signed-off-by: Harry Ciao
Acked-by: Stephen Smalley
Signed-off-by: Eric Paris -
If kernel policy version is >= 26, then the binary representation of
the role_trans structure supports specifying the class for the current
subject or the newly created object.If kernel policy version is < 26, then the class field would be default
to the process class.Signed-off-by: Harry Ciao
Acked-by: Stephen Smalley
Signed-off-by: Eric Paris
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
24 Jan, 2011
1 commit
-
Return -ENOMEM when memory allocation fails in cond_init_bool_indexes,
correctly propagating error code to caller.Signed-off-by: Davidlohr Bueso
Signed-off-by: James Morris
01 Dec, 2010
4 commits
-
We duplicate functionality in policydb_index_classes() and
policydb_index_others(). This patch merges those functions just to make it
clear there is nothing special happening here.Signed-off-by: Eric Paris
-
The sym_val_to_name type array can be quite large as it grows linearly with
the number of types. With known policies having over 5k types these
allocations are growing large enough that they are likely to fail. Convert
those to flex_array so no allocation is larger than PAGE_SIZESigned-off-by: Eric Paris
-
In rawhide type_val_to_struct will allocate 26848 bytes, an order 3
allocations. While this hasn't been seen to fail it isn't outside the
realm of possibiliy on systems with severe memory fragmentation. Convert
to flex_array so no allocation will ever be bigger than PAGE_SIZE.Signed-off-by: Eric Paris
-
policydb.c has lots of different standards on how to handle return paths on
error. For the most part transition torc=errno
if (failure)
goto out;
[...]
out:
cleanup()
return rc;Instead of doing cleanup mid function, or having multiple returns or other
options. This doesn't do that for every function, but most of the complex
functions which have cleanup routines on error.Signed-off-by: Eric Paris
21 Oct, 2010
3 commits
-
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: Eric Paris
Signed-off-by: James Morris -
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: Eric Paris
Signed-off-by: James Morris -
type is not used at all, stop declaring and assigning it.
Signed-off-by: Eric Paris
Acked-by: Stephen Smalley
Signed-off-by: James Morris
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 -
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 -
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 -
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
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
09 Apr, 2010
1 commit
-
Fix coding style in security/
Signed-off-by: Zhitong Wang
Signed-off-by: James Morris
09 Mar, 2010
1 commit
08 Mar, 2010
1 commit
-
Several places strings tables are used that should be declared
const.Signed-off-by: Stephen Hemminger
Signed-off-by: James Morris
04 Feb, 2010
1 commit
-
Allow runtime switching between different policy types (e.g. from a MLS/MCS
policy to a non-MLS/non-MCS policy or viceversa).Signed-off-by: Guido Trentalancia
Acked-by: Stephen Smalley
Signed-off-by: James Morris
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
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
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
05 Aug, 2008
1 commit
-
Trivial minor fixes that change C null character style.
Signed-off-by: Vesa-Matti Kari
Signed-off-by: James Morris
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
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 -
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
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 -
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