Commit graph

1130 commits

Author SHA1 Message Date
Stephen Smalley
fea6e66fad Allow kernel domain, not init domain, to set SELinux enforcing mode.
As per the discussion in:
https://android-review.googlesource.com/#/c/71184/

init sets the enforcing mode in its code prior to switching to
the init domain via a setcon command in the init.rc file.  Hence,
the setenforce permission is checked while still running in the
kernel domain.  Further, as init has no reason to ever set the
enforcing mode again, we do not need to allow setenforce to the
init domain and this prevents reverting to permissive
mode via an errant write by init later.  We could technically
dontaudit the kernel setenforce access instead since the first
call to setenforce happens while still permissive (and thus we
never need to allow it in policy) but we allow it to more accurately
represent what is possible.

Change-Id: I70b5e6d8c99e0566145b9c8df863cc8a34019284
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 12:02:01 -05:00
Nick Kralevich
a6c9cdfff2 am 9e8b8d9f: Revert "Allow kernel domain, not init domain, to set SELinux enforcing mode."
* commit '9e8b8d9fdfcdb6b3e8af3349df186c2ab81a9733':
  Revert "Allow kernel domain, not init domain, to set SELinux enforcing mode."
2013-12-06 08:54:57 -08:00
Nick Kralevich
9e8b8d9fdf Revert "Allow kernel domain, not init domain, to set SELinux enforcing mode."
The build is broken. Reverting temporarily to fix breakage.

libsepol.check_assertion_helper: neverallow on line 4758 violated by allow init kernel:security { setenforce };
Error while expanding policy
make: *** [out/target/product/mako/obj/ETC/sepolicy_intermediates/sepolicy] Error 1
make: *** Waiting for unfinished jobs....


This reverts commit bf12e22514.

Change-Id: I78a05756d8ce3c7d06e1d9d27e6135f4b352bb85
2013-12-06 16:52:30 +00:00
Stephen Smalley
6c8cbac334 am bf12e225: Allow kernel domain, not init domain, to set SELinux enforcing mode.
* commit 'bf12e2251422cc8470de21dd882872b7b6f960f6':
  Allow kernel domain, not init domain, to set SELinux enforcing mode.
2013-12-06 08:25:35 -08:00
Stephen Smalley
bf12e22514 Allow kernel domain, not init domain, to set SELinux enforcing mode.
As per the discussion in:
https://android-review.googlesource.com/#/c/71184/

init sets the enforcing mode in its code prior to switching to
the init domain via a setcon command in the init.rc file.  Hence,
the setenforce permission is checked while still running in the
kernel domain.  Further, as init has no reason to ever set the
enforcing mode again, we do not need to allow setenforce to the
init domain and this prevents reverting to permissive
mode via an errant write by init later.  We could technically
dontaudit the kernel setenforce access instead since the first
call to setenforce happens while still permissive (and thus we
never need to allow it in policy) but we allow it to more accurately
represent what is possible.

Change-Id: I617876c479666a03167b8fce270c82a8d45c7cc6
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 08:21:15 -08:00
Nick Kralevich
156b5db957 am 2b392fcc: Move lmkd into it\'s own domain.
* commit '2b392fccf35c790bdc55bdce51a196f4953644ce':
  Move lmkd into it's own domain.
2013-12-06 08:20:51 -08:00
Stephen Smalley
d5f77d7ab1 am 7adb999e: Restrict the ability to set usermodehelpers and proc security settings.
* commit '7adb999e701ee96356c506ffa93fce190791e8b7':
  Restrict the ability to set usermodehelpers and proc security settings.
2013-12-06 08:20:50 -08:00
Nick Kralevich
2b392fccf3 Move lmkd into it's own domain.
lmkd low memory killer daemon

The kernel low memory killer logic has been moved to a new daemon
called lmkd.  ActivityManager communicates with this daemon over a
named socket.

This is just a placeholder policy, starting off in unconfined_domain.

Change-Id: Ia3f9a18432c2ae37d4f5526850e11432fd633e10
2013-12-06 08:16:39 -08:00
Stephen Smalley
549550760e Make tee enforcing.
Change-Id: I5db2b0897aa43ccefad51b1b7fcfd0d643249384
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:45 -05:00
Stephen Smalley
1c670ccdbd Make watchdogd enforcing.
Change-Id: I04969ca94d27535b3cdcfad55f092f98592b22f7
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:45 -05:00
Stephen Smalley
6463c49d07 Make radio enforcing.
Change-Id: I3522c38a6019a42acbdd7221240caec54b89aee1
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:44 -05:00
Stephen Smalley
cc9645436f Make mediaserver enforcing.
Change-Id: I3237c2f3629b2e9be7b2e20f5c3189313efd49e5
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:43 -05:00
Stephen Smalley
edc8f384b5 Make media_app enforcing.
Change-Id: Ide025633478980e3dfc62085a8a518ffd847e1cd
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:43 -05:00
Stephen Smalley
56a1a7e9f4 Make nfc enforcing.
Change-Id: Ibb350951c9ec06feeb620358d3a207cedf8934c0
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:43 -05:00
Stephen Smalley
1b556c3270 Make ping enforcing.
Change-Id: Ib43bc4027e74660f653ec90335741acc792739da
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:43 -05:00
Stephen Smalley
2eba9c5fa2 Make bluetooth enforcing.
Change-Id: I6243819e7c9d71c561e77014b49456e9afc11153
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:42 -05:00
Stephen Smalley
a1618401f8 Make debuggerd enforcing.
Change-Id: If5b7206192cf93d9989b734304db0374429c04d5
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 10:25:42 -05:00
Stephen Smalley
7adb999e70 Restrict the ability to set usermodehelpers and proc security settings.
Limit the ability to write to the files that configure kernel
usermodehelpers and security-sensitive proc settings to the init domain.
Permissive domains can also continue to set these values.

The current list is not exhaustive, just an initial set.
Not all of these files will exist on all kernels/devices.
Controlling access to certain kernel usermodehelpers, e.g. cgroup
release_agent, will require kernel changes to support and cannot be
addressed here.

Expected output on e.g. flo after the change:
ls -Z /sys/kernel/uevent_helper /proc/sys/fs/suid_dumpable /proc/sys/kernel/core_pattern /proc/sys/kernel/dmesg_restrict /proc/sys/kernel/hotplug /proc/sys/kernel/kptr_restrict /proc/sys/kernel/poweroff_cmd /proc/sys/kernel/randomize_va_space /proc/sys/kernel/usermodehelper
-rw-r--r-- root     root              u:object_r:usermodehelper:s0 uevent_helper
-rw-r--r-- root     root              u:object_r:proc_security:s0 suid_dumpable
-rw-r--r-- root     root              u:object_r:usermodehelper:s0 core_pattern
-rw-r--r-- root     root              u:object_r:proc_security:s0 dmesg_restrict
-rw-r--r-- root     root              u:object_r:usermodehelper:s0 hotplug
-rw-r--r-- root     root              u:object_r:proc_security:s0 kptr_restrict
-rw-r--r-- root     root              u:object_r:usermodehelper:s0 poweroff_cmd
-rw-r--r-- root     root              u:object_r:proc_security:s0 randomize_va_space
-rw------- root     root              u:object_r:usermodehelper:s0 bset
-rw------- root     root              u:object_r:usermodehelper:s0 inheritable

Change-Id: I3f24b4bb90f0916ead863be6afd66d15ac5e8de0
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-06 09:44:38 -05:00
The Android Open Source Project
b96f677cf0 Merge commit '4ab298359613736281e10accaed3a6ffe1fe590a' into HEAD 2013-12-05 17:26:00 -08:00
Robert Craig
aa376831e8 Fix new rild denials.
Denials seen on hammerhead but seem
appropriate for general policy.

<5>[ 8.339347] type=1400 audit(3731546.390:17): avc: denied { ioctl } for pid=314 comm="rild" path="socket:[7996]" dev="sockfs" ino=7996 scontext=u:r:rild:s0 tcontext=u:r:rild:s0 tclass=socket
<5>[ 8.339065] type=1400 audit(3731546.390:16): avc: denied { create } for pid=314 comm="rild" scontext=u:r:rild:s0 tcontext=u:r:rild:s0 tclass=socket
<5>[ 11.232121] type=1400 audit(3731549.289:22): avc: denied { read } for pid=620 comm="rild" scontext=u:r:rild:s0 tcontext=u:r:rild:s0 tclass=socket

Change-Id: Ieaca5360afbb44d5da21c7c24bdd5e7c5758f0a2
2013-12-05 17:37:25 -05:00
Robert Craig
b2547644ef Drop tegra specific label from policy.
This label was originally used for Motorola
Xoom devices. nvmap is the tegra gpu memory
manager and the various nvhost drivers are
for tegra graphics related functionality,
i.e. display serial interface, image signal
processor, or media processing stuff.

Only grouper and tilapia presently need this
policy.

Change-Id: I2a7000f69abf3185724d88d428e8237e0ca436ec
2013-12-05 13:29:07 -08:00
Nick Kralevich
8824c552d6 Merge "Allow SELinuxPolicyInstallReceiver to work." 2013-12-05 20:07:49 +00:00
Stephen Smalley
d99e6d5fa1 Restrict the ability to set SELinux enforcing mode to init.
Also make su and shell permissive in non-user builds to allow
use of setenforce without violating the neverallow rule.

Change-Id: Ie76ee04e90d5a76dfaa5f56e9e3eb7e283328a3f
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-02 15:59:04 -05:00
Stephen Smalley
a49ba927e3 Allow SELinuxPolicyInstallReceiver to work.
Change-Id: I10006f43c142f07168e2ea0f4f5f7af68d03e504
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-02 14:22:17 -05:00
Nick Kralevich
51ce2f00c5 Merge "Make the isolated_app domain enforcing." 2013-12-02 17:11:34 +00:00
Stephen Smalley
081aed2133 Default to socket_device for anything under /dev/socket.
Otherwise sockets that have no specific entry match the /dev(/.*) entry
instead, leaving them in device type rather than socket_device type.
Every socket should get its own entry regardless, but this at least puts
it into a more specific type by default.

Change-Id: I97f7999af7f9f83484d3a51440dda791d3726f1a
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-02 09:02:22 -05:00
Stephen Smalley
08ecc02821 Make the isolated_app domain enforcing.
Change-Id: I11be7d1713dd7cb35b8046503a09e42567e53d86
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-12-02 08:54:31 -05:00
Nick Kralevich
476855357b Allow write access to ashmem allocated regions
Allow tmpfs_domains the ability to write to ashmem allocated
regions. At least one Google internal app does this, and switching
untrusted_app into enforcing causes the following denial:

<5>[  291.791423] type=1400 audit(1385587240.320:79): avc:  denied  { write } for  pid=3774 comm="XXXXXXXXXXXX" path=2F6465762F6173686D656D202864656C6574656429 dev="tmpfs" ino=16937 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:untrusted_app_tmpfs:s0 tclass=file

path=/dev/ashmem (deleted)

Bug: 11891764
Change-Id: I64d414c055cd02481ebf69994fad65d777d8381d
2013-11-27 13:36:48 -08:00
Stephen Smalley
2ffd52a472 am 043b9027: Confine watchdogd, but leave it permissive for now.
* commit '043b9027b3cc1c055e4ec5917f5d0d9bdc69005f':
  Confine watchdogd, but leave it permissive for now.
2013-11-22 17:22:09 -08:00
The Android Open Source Project
6af0cc2430 Merge commit '060f6fa67e1d9779d2d8357659ae530d65171faa' into HEAD 2013-11-22 10:35:15 -08:00
Stephen Smalley
043b9027b3 Confine watchdogd, but leave it permissive for now.
Change-Id: If2285e927cb886956b3314dd18384145a1ebeaa9
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-11-21 10:55:56 -05:00
Nick Kralevich
7ef2b39f96 am 1ed3caf7: Merge "Add support for duplicate allow rule detection (-D / --dups)."
* commit '1ed3caf736d59f11d6c39edb3de2e0d0cd5ca71f':
  Add support for duplicate allow rule detection (-D / --dups).
2013-11-19 12:07:55 -08:00
Nick Kralevich
1ed3caf736 Merge "Add support for duplicate allow rule detection (-D / --dups)." 2013-11-19 20:04:20 +00:00
Stephen Smalley
bec54f42ed Add support for duplicate allow rule detection (-D / --dups).
Usage:
sepolicy-analyze -D -P out/target/product/<board>/root/sepolicy

Displays duplicate allow rules, i.e. pairs of allow rules that grant
the same permissions where one allow rule is written directly in terms
of individual types and the other is written in terms of attributes
associated with those same types.  The rule with individual types is
a candidate for removal.  The rule with individual types may be directly
represented in the source policy or may be a result of expansion of
a type negation (e.g. domain -foo -bar is expanded to individual allow
rules by the policy compiler).  Domains with unconfineddomain will
typically have such duplicate rules as a natural side effect and can
be ignored.

Also add a tools/README with a description of all of the tools.

Change-Id: I07838dbd22c5cc8a4a65b57003ccae38129050f5
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-11-18 16:11:36 -08:00
Nick Kralevich
65d4e8355b am 006260e5: Merge "Confine hostapd, but leave it permissive for now."
* commit '006260e528f4bcd6fa7db6e1acc5d38224eb401b':
  Confine hostapd, but leave it permissive for now.
2013-11-18 13:07:58 -08:00
Nick Kralevich
006260e528 Merge "Confine hostapd, but leave it permissive for now." 2013-11-18 21:05:05 +00:00
Nick Kralevich
2c8eef873e am 2b939e8c: Merge "Confine ping, but leave it permissive for now."
* commit '2b939e8cabab28db2d7e2015ecab59e1cbdbc442':
  Confine ping, but leave it permissive for now.
2013-11-18 12:03:31 -08:00
Nick Kralevich
2b939e8cab Merge "Confine ping, but leave it permissive for now." 2013-11-18 19:59:30 +00:00
Stephen Smalley
945fb56766 Confine hostapd, but leave it permissive for now.
Change-Id: I23a2c568e9fdd51c6c09c6c80a7ce9f2b5bd4966
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-11-18 11:25:10 -08:00
Jeff Sharkey
4ab2983596 am 35e8dcc9: Merge "Let vold mount OBB files on external storage." into klp-dev
* commit '35e8dcc9ba40c6419f63d0a516c0995d3064f96e':
  Let vold mount OBB files on external storage.
2013-11-14 16:26:18 -08:00
Jeff Sharkey
35e8dcc9ba Merge "Let vold mount OBB files on external storage." into klp-dev 2013-11-15 00:19:25 +00:00
Jeff Sharkey
80176dc445 Let vold mount OBB files on external storage.
Fixes this specific violation:

type=1400 audit(1384468728.202:16): avc:  denied { read write } for
pid=271 comm="vold" name="test1.obb" dev="fuse" ino=3100664872
scontext=u:r:vold:s0 tcontext=u:object_r:sdcard_internal:s0
tclass=file

Bug: 11693888
Change-Id: I45d30ecabdf0bc8871f3dd67b5695ac909109d9a
2013-11-14 16:11:56 -08:00
Nick Kralevich
e0068ecce3 am 24fb24f7: am ae49e7a3: Merge "Confine tee, but leave it permissive for now."
* commit '24fb24f7ea1bf74bc1234394b81955e0aab6943f':
  Confine tee, but leave it permissive for now.
2013-11-14 11:37:53 -08:00
Nick Kralevich
24fb24f7ea am ae49e7a3: Merge "Confine tee, but leave it permissive for now."
* commit 'ae49e7a3691137b5276254074b2c282bcdfee523':
  Confine tee, but leave it permissive for now.
2013-11-14 11:34:11 -08:00
Nick Kralevich
ae49e7a369 Merge "Confine tee, but leave it permissive for now." 2013-11-14 19:29:27 +00:00
Nick Kralevich
c6a3f60cbe am 678420e0: am 6ce3d60c: Merge "Confine rild, but leave it permissive for now."
* commit '678420e023c6f143fb99cfed031397e732960410':
  Confine rild, but leave it permissive for now.
2013-11-14 08:50:01 -08:00
Stephen Smalley
87d0deb3ab am 67a53232: am b1cb3205: Confine wpa_supplicant, but leave it permissive for now.
* commit '67a53232cec967ca53e6f7284fd582a5bdd3eb69':
  Confine wpa_supplicant, but leave it permissive for now.
2013-11-14 08:50:00 -08:00
Nick Kralevich
678420e023 am 6ce3d60c: Merge "Confine rild, but leave it permissive for now."
* commit '6ce3d60ca39dd37f0de4bcd81620b3611cd28e14':
  Confine rild, but leave it permissive for now.
2013-11-14 08:46:49 -08:00
Stephen Smalley
67a53232ce am b1cb3205: Confine wpa_supplicant, but leave it permissive for now.
* commit 'b1cb3205cad978399fa7c9dcafed607fe5d07de6':
  Confine wpa_supplicant, but leave it permissive for now.
2013-11-14 08:46:49 -08:00
Nick Kralevich
6ce3d60ca3 Merge "Confine rild, but leave it permissive for now." 2013-11-14 16:44:24 +00:00