Commit graph

1248 commits

Author SHA1 Message Date
Bill Yi
a34377d480 Add NOTICE
Change-Id: Ica08aa5c3e6da2f786529100f526b846b873e351
2015-05-22 11:20:50 -07:00
Jeff Vander Stoep
e537f38384 Use prebuilt in-tree audit2allow
Linux only. Audit2allow is a python executable. Install a sh wrapper around
the python executable that points to the appropriate prebuilt library and
python module.

Change-Id: I991cfec229e542d2489672fbbc597feca8ec33cc
2015-05-18 09:17:55 -07:00
Bill Yi
10010cfc4c Add MODULE_LICENSE_GPL
Change-Id: I3a86c3d0fb42d840776b09f902481294a1eeab02
2015-05-14 14:54:21 -07:00
Jeffrey Vander Stoep
3c4d14e332 Merge "Revert "Move host functionality to common selinux dir"" 2015-05-14 18:04:59 +00:00
Jeffrey Vander Stoep
776434aae9 Revert "Move host functionality to common selinux dir"
This change breaks the Mac build due to no stdio_ext.h

This reverts commit 527d945abc.

Change-Id: Ifdaba985207932690e34a479541c7619b78d6aad
2015-05-14 17:53:33 +00:00
Jeff Vander Stoep
53416f6cf0 Merge "remove unused header stdio_ext.h" 2015-05-14 17:14:43 +00:00
Jeff Vander Stoep
3792d7e2f7 remove unused header stdio_ext.h
Fixes MAC build

Change-Id: Icceb30ad1b8f63bb88c2baf21facf3a4e48b0664
2015-05-14 16:54:24 +00:00
Jeff Vander Stoep
527d945abc Move host functionality to common selinux dir
Device side libselinux has Android specific modifications.
but host side tools do not. Move host functionality over to common
selinux directory. This allows tools with libselinux dependency e.g.
audit2allow to be built in tree.

Change-Id: I10a7174b415bad7b5154c382a55eb10a8ed52fa5
2015-05-13 14:56:37 -07:00
Jeff Vander Stoep
c617134621 Merge "Move to common directory versions of selinux tools" 2015-05-11 16:46:01 +00:00
Jeff Vander Stoep
9388edbd4b Move to common directory versions of selinux tools
Migrate selinux tools to common directory for consistency with
the external selinux project. Build libsepol and checkpolicy

Change-Id: Ifb6618d27e95fadf29cf735776c8d4d439589347
2015-05-11 08:55:27 -07:00
Jeff Vander Stoep
3b098081a5 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Fixes Mac build

Change-Id: I707c462f6ee33ed5e78a3f7b704ffdb8d646cff1
2015-05-08 14:37:28 -07:00
James Carter
17381435f8 Update libsepol ChangeLog.
Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
2015-05-08 11:03:13 -04:00
James Carter
8ebb97d0be Replace fmemopen() with internal function in libsepol.
Created a new function, get_line(), to replace the use of fmemopen()
and getline() in module_to_cil.c since fmemopen() is not available
on Darwin.

Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
2015-05-08 10:58:09 -04:00
Stephen Smalley
fe0366b8ed Update libselinux ChangeLog. 2015-05-07 12:47:21 -04:00
Richard Haines
a351eb01a8 libselinux: Fix core dumps with corrupt *.bin files
Check buffer address limits when processing *.bin files
to catch any over-runs. On failure process text file instead.

To test, the bin files were corrupted by adding and removing
various bits of data. Various file sizes were also checked and
all were caught by the patch.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
2015-05-07 12:00:07 -04:00
Jeffrey Vander Stoep
4e8d805847 Revert "Use common directory versions of selinux tools"
Darwin does not support fmemopen.

This reverts commit dfac181e22.

Change-Id: I6967c3bd189de770a0891b5c8ad4b2cd61989a5e
2015-05-06 21:49:42 +00:00
Jeff Vander Stoep
dfac181e22 Use common directory versions of selinux tools
Migrate selinux tools to common directory for consistency with
the external selinux project. Use projects libsepol, checkpolicy,
and secilc.

Change-Id: Ibc623b751dfe4e7f5119d7dd3ddffa39e68d9ebe
2015-05-06 13:17:18 -07:00
Nick Kralevich
e39c09f418 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Change-Id: Ib31d805f4abcc7bebc923a5d9fa35ce7aa6e29b4
2015-05-06 10:15:44 -07:00
Stephen Smalley
4d0d9c7004 Update libselinux ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-05-06 11:59:18 -04:00
Richard Haines
e7f970ffd1 libselinux: Add selabel partial and best match APIs
Add support for new API functions selabel_partial_match and
selabel_lookup_best_match ported from the Android libselinux
fork.

Add supporting man(3) pages and test utilities: selabel_lookup,
selabel_lookup_best_match and selabel_partial_match.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-05-06 11:58:44 -04:00
James Carter
9ab426eea1 Update libsepol ChangeLog.
Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
2015-05-05 16:08:41 -04:00
Yuli Khodorkovskiy
c3345c58a4 libsepol/cil: Verify users prior to evaluating users
If a userlevel or userrange statement is missing from a policy,
evaluate_level_expression() and evaluate_levelrange_expression, respectively
will have a NULL pointer dereference caused by a missing level in a user.

Add cil_pre_verify() which verifies users have a valid level. Also, move loop
checking in classpermissions into cil_pre_verify().

This fixes https://github.com/SELinuxProject/cil/issues/1.

Signed-off-by: Yuli Khodorkovskiy <ykhodorkovskiy@tresys.com>
2015-05-05 16:00:03 -04:00
Nick Kralevich
fc6bce3ea5 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Change-Id: I64e3e823798bf39236a39046ee27bd28eb28b02c
2015-04-28 12:59:06 -07:00
Stephen Smalley
34e196c3c2 Update checkpolicy ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-28 08:29:44 -04:00
Jeff Vander Stoep
7f1ec68362 dispol: display operations as ranges
Displays operations ranges more concisely. E.g.

{ 0x8901-0x8930 }

instead of

{ 0x8901 0x8902 0x8903 0x8904 80x8905 0x0806 ... 0x8930 }

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-28 08:29:24 -04:00
Nick Kralevich
bc109d0f85 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Change-Id: I45ecaeef69bf47064d653836cd46590937eef372
2015-04-25 18:09:59 -07:00
Stephen Smalley
994db9d390 Update libsepol ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-24 14:32:01 -04:00
Stephen Smalley
7c912dbc7c libsepol: Binary modules do not support ioctl rules.
Prevent writing a binary policy module if the source
included an ioctl operation rule because we do not support ioctl
operation rules in the binary module format.  It doesn't seem
worthwhile to introduce a new binary policy module version since
CIL is now merged and we will have to implement the support in CIL
regardless; might as well only support it in CIL modules.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-24 14:24:04 -04:00
Stephen Smalley
11f2e159f6 Update checkpolicy ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-23 08:45:20 -04:00
Stephen Smalley
6dafd3ded9 dispol: Extend to display operations.
Also drop expanding of rules; just display the rules in their
original form.  I think expansion was a relic of an older policy
version where we did not preserve attributes in the kernel policy.
In any event, it seems more useful to display the rules unmodified.

Change-Id: I85095a35cfb48138cd9cf01cde6dd0330e342c61
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-23 08:42:07 -04:00
Steve Lawrence
ef1637b55c Update libsemanage ChangeLog 2015-04-23 08:35:39 -04:00
Jason Zaman
f5c226810d libsemanage: do not copy contexts in semanage_migrate_store
The modules from the old store were previously copied to the new one
using setfscreatecon and shutil.copy2(). Now that refpolicy has rules
about the new policy location[1], copying the contexts is redundant.

More importantly, the setcreatefscon caused a constraint violation[2]
which made the migration fail. In python3, shutil.copy2() copies xattrs
as well which again causes problems. shutil.copy() is enough for our
needs here as it will copy the file and permissions in both py2 and 3.
We do not need the extra things that copy2() does (mtime, xattr, etc).

[1] http://oss.tresys.com/pipermail/refpolicy/2014-December/007511.html

[2]
type=AVC msg=audit(1429438272.872:1869): avc:  denied  { create } for  pid=28739 comm="semanage_migrat" name="strict" scontext=staff_u:sysadm_r:semanage_t tcontext=system_u:object_r:semanage_store_t tclass=dir permissive=0
	constrain dir { create relabelfrom relabelto } ((u1 == u2 -Fail-)  or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED
allow semanage_t semanage_store_t:dir create;

Signed-off-by: Jason Zaman <jason@perfinion.com>
Acked-by: Steve Lawrence <slawrence@tresys.com>

Changes from v1:
 - Changed some methods to not take a src param anymore.
2015-04-23 08:35:39 -04:00
Stephen Smalley
a2ceeba03c Update libsepol and checkpolicy ChangeLogs.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-23 08:33:18 -04:00
Jeff Vander Stoep
80bc7ee8fa Add support for ioctl command whitelisting
Adds support for new policy statements whitelisting individual ioctl
commands. Ioctls provide many of the operations necessary for driver control.
The typical driver supports a device specific set of operations accessible
by the ioctl system call and specified by the command argument. SELinux
provides per operation access control to many system operations e.g. chown,
kill, setuid, ipc_lock, etc. Ioclts on the other hand are granted on a per
file descriptor basis using the ioctl permission, meaning that the set of
operations provided by the driver are granted on an all-or-nothing basis.
In some cases this may be acceptable, but often the same driver provides a
large and diverse set of operations such as benign and necessary functionality
as well as dangerous capabilities or access to system information that should
be restricted.

Example policy:
allow <source> <target>:<class> { 0x8900-0x8905 0x8910 }
auditallow <source> <target>:<class> 0x8901

The ioctl permission is still required in order to make an ioctl call. If no
individual ioctl commands are specified, only the ioctl permission is
checked by the kernel - i.e. status quo. This allows ioctl whitelisting to
done in a targeted manner, protecting desired drivers without requiring every
ioctl command to be known and specified before use and otherwise allowing
existing policy to be used as-is.

This only implements ioctl whitelisting support for monolithic kernel policies
built via checkpolicy. Support for modules and CIL remains to be done.

Bug: 19419509
Change-Id: I198e8c9279b94d8ce4ae5625018daa99577ee970
Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
Acked-by:  Stephen Smalley <sds@tycho.nsa.gov>
2015-04-23 08:30:33 -04:00
Steve Lawrence
de4f82bb7f Move ChangeLog entry to the correct project 2015-04-21 08:49:32 -04:00
Steve Lawrence
6f79e5ed9e Update libselinux ChangeLog 2015-04-21 08:21:17 -04:00
Miro Hrončok
42ac8d6dc4 libselinux: selinux.py - use os.walk() instead of os.path.walk()
os.path.walk() function is deprecated and has been removed in Python 3

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
Acked-by: Steve Lawrence <slawrence@tresys.com>
2015-04-21 08:15:02 -04:00
Nick Kralevich
ba1e96df78 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Change-Id: I55e060dc95c0bab0d17509137364d4a50d51a321
2015-04-20 16:29:29 -07:00
Stephen Smalley
27d5377cc7 Updated libselinux ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-17 12:38:10 -04:00
Stephen Smalley
685f4aeead libselinux: is_selinux_enabled(): drop no-policy-loaded test.
SELinux can be disabled via the selinux=0 kernel parameter or via
/sys/fs/selinux/disable (triggered by setting SELINUX=disabled in
/etc/selinux/config).  In either case, selinuxfs will be unmounted
and unregistered and therefore it is sufficient to check for the
selinuxfs mount.  We do not need to check for no-policy-loaded and
treat that as SELinux-disabled anymore; that is a relic of Fedora Core 2
days.  Drop the no-policy-loaded test, which was a bit of a hack anyway
(checking whether getcon_raw() returned "kernel" as that can only happen
if no policy is yet loaded and therefore security_sid_to_context() only
has the initial SID name available to return as the context).

May possibly fix https://bugzilla.redhat.com/show_bug.cgi?id=1195074
by virtue of removing the call to getcon_raw() and therefore avoiding
use of tls on is_selinux_enabled() calls.  Regardless, it will make
is_selinux_enabled() faster and simpler.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-17 09:38:18 -04:00
Nick Kralevich
6e3d1df44f Revert "kick automerger"
This reverts commit 271a35460e.
2015-04-16 16:38:30 -07:00
Nick Kralevich
271a35460e kick automerger
Change-Id: I4e0c5ccf343d4f59c7b93ba204d1117190ca26a2
2015-04-16 16:37:49 -07:00
Nick Kralevich
bb2d6b3fc8 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Update to tip-of-tree selinux code.
2015-04-16 12:27:31 -07:00
Stephen Smalley
220151c0ef Update policycoreutils ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-16 11:41:46 -04:00
Petr Lautrbach
219eea83ce policycoreutils: setfiles/restorecon: fix -r/-R option
A spec file was incorrectly stored as rootpath when -r option was used

Fixes:
/sbin/setfiles:  /tmp/install_root is not located in /etc/selinux/targeted/contexts/files/file_contexts

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
2015-04-16 11:40:55 -04:00
Stephen Smalley
b03543cdc0 Update policycoreutils ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-16 09:52:05 -04:00
Stephen Smalley
974f565415 Update libselinux ChangeLog.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-16 09:51:31 -04:00
Stephen Smalley
549912d229 org.selinux.policy: Require auth_admin_keep for all actions.
Fedora permits obtaining local policy customizations and the list
of policy modules without admin authentication, but we would prefer
more conservative defaults upstream.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-16 09:40:31 -04:00
Stephen Smalley
082f1d1274 libselinux: Remove deprecated mudflap option.
The mudflap run time checker was removed in GCC 4.9.  The
option no longer does anything and triggers a warning from gcc 4.9
and later.  Remove it.  We might want to add -fsanitize=address
to enable AddressSanitizer in its place, but that should be a separate
change.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-04-16 08:23:55 -04:00
Nick Kralevich
39b5c1028c Add empty top level Android.mk / CleanSpec.mk files
Needed to allow Android to keep building with a copy of the SELinux
source code checked into external/selinux

Bug: 19963152
Change-Id: I4e192bb6ca5d185e11540aca7253e729d92a00c1
2015-04-16 07:54:09 -04:00