Commit graph

3506 commits

Author SHA1 Message Date
dcashman
cd82557d40 Restrict service_manager find and list access.
All domains are currently granted list and find service_manager
permissions, but this is not necessary.  Pare the permissions
which did not trigger any of the auditallow reporting.

Bug: 18106000
Change-Id: Ie0ce8de2af8af2cbe4ce388a2dcf4534694c994a
2014-12-15 10:09:24 -08:00
Nick Kralevich
b7d0ae3aca Merge "sepolicy: allow system apps to access ASEC" 2014-12-12 16:48:28 +00:00
Pawit Pornkitprasan
c06ed8f7b2 sepolicy: allow system apps to access ASEC
Required for Settings to show name/icon of apps on sd card
(permission copied from untrusted_app)

Also removed duplicate permission (from domain) in untrusted_app

Change-Id: Ib2b3bee4dfb54ad5e45b392fd9bfd65add4a00bf
2014-12-12 13:58:39 +07:00
Stephen Smalley
2c75918505 Allow fcntl F_SETLK on sockets.
Addresses denials such as:
type=1400 : avc: denied { lock } for comm="PushCheckSendS" path="socket:[1834573]" dev="sockfs" ino=X scontext=u:r:untrusted_app:s0 tcontext=u:r:untrusted_app:s0 tclass=tcp_socket

Change-Id: Idbf6120cca9df634e2f8a876fd1cd836551e5ad7
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-12-11 11:45:51 -05:00
Brian Carlstrom
fc6214bf5d add permissions for adb shell to create symlinks in /data/local/tmp
Bug: 18485243
Change-Id: Ic17baa0767ee1f1a27a3338558b86482ca92765e
2014-12-10 15:45:09 -08:00
dcashman
10ecd05df3 Add neverallow rule for set_context_mgr.
Resubmission of commit: 76f3fe33d7

Removed conflicting rule from unconfined domain.

Change-Id: I3e6da8922ebf636f1cd8ceefea4291d043a28ab7
2014-12-10 13:50:39 -08:00
dcashman
6322a3297b Revert " Add neverallow rule for set_context_mgr."
Fix build due to goldfish neverallow conflicts.

This reverts commit 76f3fe33d7.
2014-12-09 18:14:08 +00:00
dcashman
76f3fe33d7 Add neverallow rule for set_context_mgr.
Change-Id: Ie7c2bf623dcfe246fa5e60b0775b6bb38869d8cb
2014-12-05 14:34:41 -08:00
Daniel Cashman
0be02b360f Merge "Fix sepolicy-analyze build with different toolchains" 2014-12-02 20:33:23 +00:00
Stephen Smalley
7d7151647f Do not allow isolated_app to directly open app data files.
Only allow it to read/write/stat already open app data files
received via Binder or local socket IPC.

Change-Id: Ie66f240e109410a17aa93d9d5dea4c2b87d47009
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-12-02 18:01:43 +00:00
William Roberts
47c1461156 Fix sepolicy-analyze build with different toolchains
host C: sepolicy-analyze <= external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c
external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c: In function 'usage':
external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c:30:5: error: 'for' loop initial declarations are only allowed in C99 mode
external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c:30:5: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [out/host/linux-x86/obj/EXECUTABLES/sepolicy-analyze_intermediates/sepolicy-analyze.o] Error 1

Change-Id: I9222e447b032d051c251c9718e2b8d5ffb9e9c35
2014-12-01 11:45:54 -08:00
dcashman
6963655194 Remove entropy from service_contexts.
Commit: 9287e0dd272b85b475e33bcbd7d868517a0f98f9 removed the registration
of EntropyMixer with servicemanager, so it no longer needs a context.

Bug: 18106000

Cherry-pick of commit: 7cfef98ce7

Change-Id: I9aeb35e7ffde75090f4234ea193514fb883b1425
2014-11-26 13:52:04 -08:00
Nick Kralevich
c48971f69f allow system_server to set ro.build.fingerprint
Some devices leave "ro.build.fingerprint" undefined at build time,
since they need to build it from the components at runtime.
See 5568772e81
for details.

Allow system_server to set ro.build.fingerprint

Addresses the following denial/error:

  avc:  denied  { set } for property=build.fingerprint scontext=u:r:system_server:s0 tcontext=u:object_r:default_prop:s0 tclass=property_service
  init: sys_prop: permission denied uid:1000  name:ro.build.fingerprint

Bug: 18188956
Change-Id: I98b25773904a7be3e3d2926daa82c1d08f9bcc29
2014-11-18 22:44:31 +00:00
William Roberts
f330f37529 Remove network shell script
This seems to not really being used, especially considering
that the init.rc does not have a oneshot service for it, and its
not using the build_policy() and other things to even make it
configurable.

Change-Id: I964f94b30103917ed39cf5d003564de456b169a5
2014-11-13 07:34:39 -08:00
Jeff Hao
9ab0194ae6 App: add permissions to read symlinks from dalvik cache.
Bug: 18035729

(cherry picked from commit 6f201ddc79)

Change-Id: I9865932ca87acefe0ab7feb3e6dc875f3d64276d
2014-11-12 13:20:42 -08:00
Nick Kralevich
f19cca3ee1 Merge "allow run-as to access /data/local/tmp" 2014-11-10 19:33:06 +00:00
Stephen Smalley
1c16abd340 Allow init to chown/chmod character devices.
init.rc files can potentially chown/chmod any character device, so
allow it for everything except for kmem (prohibited by neverallow).
While we could whitelist each of the device types, doing so would also
require device-specific changes for the device-specific types and
may be difficult to maintain.

Resolves (permissive) denials such as:
avc:  denied  { read } for  pid=1 comm="init" name="ttySAC0" dev="tmpfs" ino=4208 scontext=u:r:init:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1

avc:  denied  { open } for  pid=1 comm="init" name="ttySAC0" dev="tmpfs" ino=4208 scontext=u:r:init:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1

avc:  denied  { setattr } for  pid=1 comm="init" name="ttySAC0" dev="tmpfs" ino=4208 scontext=u:r:init:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1

avc:  denied  { read } for  pid=1 comm="init" name="smd7" dev="tmpfs" ino=6181 scontext=u:r:init:s0 tcontext=u:object_r:radio_device:s0 tclass=chr_file

avc:  denied  { open } for  pid=1 comm="init" name="smd7" dev="tmpfs" ino=6181 scontext=u:r:init:s0 tcontext=u:object_r:radio_device:s0 tclass=chr_file

avc:  denied  { read } for  pid=1 comm="init" name="wcnss_wlan" dev="tmpfs" ino=7475 scontext=u:r:init:s0 tcontext=u:object_r:wlan_device:s0 tclass=chr_file

avc:  denied  { open } for  pid=1 comm="init" name="wcnss_wlan" dev="tmpfs" ino=7475 scontext=u:r:init:s0 tcontext=u:object_r:wlan_device:s0 tclass=chr_file

avc:  denied  { setattr } for  pid=1 comm="init" name="wcnss_wlan" dev="tmpfs" ino=7475 scontext=u:r:init:s0 tcontext=u:object_r:wlan_device:s0 tclass=chr_file

Change-Id: If8d14e9e434fab645d43db12cc1bdbfd3fc5d354
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-11-10 13:25:12 -05:00
Nick Kralevich
dd8571aa24 allow run-as to access /data/local/tmp
Otherwise denials like the following occur:

avc: denied { write } for path="/data/local/tmp/foo" dev="dm-0" ino=325769 scontext=u:r:runas:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file
avc: denied { read } for path="/data/local/tmp/foo" dev="dm-0" ino=325769 scontext=u:r:runas:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file

Steps to reproduce:

$ run-as com.google.android.talk id > /data/local/tmp/id.out
$ run-as com.google.android.talk cat < /data/local/tmp/id.out

Change-Id: I68a7b804336a3d5776dcc31622f1279380282030
2014-11-07 16:21:42 -08:00
Nick Kralevich
1795b665bf Allow recovery to create device nodes and modify rootfs
tilapia's OTA code for updating the radio image needs to
create files on rootfs and create a character device in /dev.
Add an exception for recovery the the various neverallow rules
blocking this behavior.

(cherrypick, with modifications, from 0055ea904a)

Bug: 18281224
Change-Id: I5c57afe0a10b4598fea17f9c5c833bd39551907e
2014-11-07 14:56:33 -08:00
Stephen Smalley
ee58864b95 Revert "DO NOT MERGE: Flip FORCE_PERMISSIVE_TO_UNCONFINED to true"
Change-Id I52fd5fbe30a7f52f1143f176915ce55fb6a33f87 was only intended
for lollipop, not for master.

This reverts commit 2aa727e3f0.

Change-Id: If2101939eb50cd6bbcde118b91c003d1f30d811c
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-11-07 09:50:38 -05:00
Nick Kralevich
39f92a8350 am f7e98fe2: Merge "recovery.te: add /data neverallow rules"
* commit 'f7e98fe2c988d88a4a98a1fdfd07561cef013e5c':
  recovery.te: add /data neverallow rules
2014-11-06 19:22:09 +00:00
Nick Kralevich
57df7115ca am 35a4ed80: Add wpa neverallow rule
* commit '35a4ed80a68d71df2cf138d17ea09fd782a1d73e':
  Add wpa neverallow rule
2014-11-06 19:22:03 +00:00
Nick Kralevich
f7e98fe2c9 Merge "recovery.te: add /data neverallow rules" 2014-11-06 18:58:35 +00:00
Nick Kralevich
35a4ed80a6 Add wpa neverallow rule
wpa should never trust any data coming from the sdcard. Add a
compile time assertion to make sure no rules are ever added
allowing this access.

Change-Id: I5f50a8242aa30f6cc0cfd89d82b2b153625105f6
2014-11-06 10:57:03 -08:00
Nick Kralevich
a17a266e7e recovery.te: add /data neverallow rules
Recovery should never be accessing files from /data.
In particular, /data may be encrypted, and the files within
/data will be inaccessible to recovery, because recovery doesn't
know the decryption key.

Enforce write/execute restrictions on recovery. We can't tighten
it up further because domain.te contains some /data read-only
access rules, which shouldn't apply to recovery but do.

Create neverallow_macros, used for storing permission macros
useful for neverallow rules. Standardize recovery.te and
property_data_file on the new macros.

Change-Id: I02346ab924fe2fdb2edc7659cb68c4f8dffa1e88
2014-11-05 15:30:41 -08:00
Robert Greenwalt
98ada9a6b2 am 3bcdec8a: Allow radio access to netd_pid file.
* commit '3bcdec8a1eb8afe2af48550b4478fe02bf824377':
  Allow radio access to netd_pid file.
2014-11-04 00:48:31 +00:00
Robert Greenwalt
3bcdec8a1e Allow radio access to netd_pid file.
They need to see when it changes so they know when netd bounces.

(cherrypicked from commit 71e9a7c471)

bug:18069270
Change-Id: I954cf43ff02f1d352015f128ef88b659e6d0f95a
2014-11-03 15:13:15 -08:00
Nick Kralevich
22b4eb7083 am ca62a8b7: allow coredump functionality
* commit 'ca62a8b72be35de3781c1f8f16600cfeca874ef5':
  allow coredump functionality
2014-10-31 22:22:47 +00:00
Nick Kralevich
ca62a8b72b allow coredump functionality
(cherrypick of commit d7e004ebf9)

Change-Id: I7993698ac96f21db0039681275280dbd43ff61ba
2014-10-31 15:16:29 -07:00
dcashman
4fc9805415 am bdc8c77a: Merge "Accept command-line input for neverallow-check."
* commit 'bdc8c77a737a9d0ade4c93b3c6f59a4be5a1231e':
  Accept command-line input for neverallow-check.
2014-10-31 21:25:26 +00:00
dcashman
bdc8c77a73 Merge "Accept command-line input for neverallow-check." 2014-10-31 21:21:27 +00:00
dcashman
ef4fd30672 Accept command-line input for neverallow-check.
Also, divide each sepolicy-analyze function into its own component for simplified
command-line parsing and potentially eventual modularization.

Bug: 18005561
Change-Id: I45fa07d776cf1bec7d60dba0c03ee05142b86c19
2014-10-31 11:38:32 -07:00
Stephen Smalley
82adfafab3 am c457572b: Allow init to restorecon /data directories on upgrades.
* commit 'c457572bdf4d85090582eb18db34b279967080d0':
  Allow init to restorecon /data directories on upgrades.
2014-10-30 23:43:00 +00:00
Stephen Smalley
c457572bdf Allow init to restorecon /data directories on upgrades.
Resolves (permissive) denials on upgrades from 4.4.

Change-Id: Ia9eed4938a7235c23bb65de7ad65e6e7c325dfd7
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-10-30 16:55:27 -04:00
Daniel Cashman
0a296fb019 am f3926937: Merge "Switch kernel and init to permissive_or_unconfined()."
* commit 'f39269371e24147f4a45ba281a79d800ec3e56c7':
  Switch kernel and init to permissive_or_unconfined().
2014-10-30 20:03:18 +00:00
Daniel Cashman
f39269371e Merge "Switch kernel and init to permissive_or_unconfined()." 2014-10-30 19:59:58 +00:00
Stephen Smalley
a523aaca12 Switch kernel and init to permissive_or_unconfined().
Switch the kernel and init domains from unconfined_domain()
to permissive_or_unconfined() so that we can start collecting
and addressing denials in -userdebug/-eng builds.

Also begin to address denials for kernel and init seen after
making this switch.

I intentionally did not allow the following denials on hammerhead:
avc:  denied  { create } for  pid=1 comm="init" name="memory.move_charge_at_immigrate" scontext=u:r:init:s0 tcontext=u:object_r:init_tmpfs:s0 tclass=file
avc:  denied  { open } for  pid=1 comm="init" name="memory.move_charge_at_immigrate" dev="tmpfs" ino=6550 scontext=u:r:init:s0 tcontext=u:object_r:init_tmpfs:s0 tclass=file

These occur when init.rc does:
write /sys/fs/cgroup/memory/memory.move_charge_at_immigrate 1
because the prior command to mount the cgroup failed:
mount cgroup none /sys/fs/cgroup/memory memory

I think this is because that cgroup is not enabled in the
kernel configuration.  If the cgroup mount succeeded,
then this would have been a write to a cgroup:file and
would have been allowed already.

Change-Id: I9d7e31bef6ea91435716aa4312c721fbeaeb69c0
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-10-29 15:35:35 -04:00
Igor Murashkin
f48951a939 am 0ae33a8d: Merge "zygote/dex2oat: Grant additional symlink permissions"
* commit '0ae33a8d1439800439db1c22da0d9a2073fb3a42':
  zygote/dex2oat: Grant additional symlink permissions
2014-10-29 12:32:35 +00:00
Igor Murashkin
0ae33a8d14 Merge "zygote/dex2oat: Grant additional symlink permissions" 2014-10-28 22:35:07 +00:00
Nick Kralevich
029e1bc575 am 5fad3d98: recovery: allow changing unlabeled symbolic links
* commit '5fad3d98deadde8900130fe8980032728ad75fd0':
  recovery: allow changing unlabeled symbolic links
2014-10-28 04:46:32 +00:00
Nick Kralevich
4d9648e3e4 am b519949d: system_server: assert app data files never opened directly
* commit 'b519949df150ebe4fc9bf3db52542bb5d9238d4e':
  system_server: assert app data files never opened directly
2014-10-28 04:31:29 +00:00
Igor Murashkin
83c5612e69 zygote/dex2oat: Grant additional symlink permissions
* zygote needs to be able to symlink from dalvik cache to system
  to avoid having to copy boot.oat
  (when the boot.oat file was built with --compile-pic)
* dex2oat needs to be able to read the symlink in the dalvik cache
  (the one that zygote creates)

Bug: 18035729
Change-Id: Ie1acad81a0fd8b2f24e1f3f07a06e6fdb548be62
2014-10-27 17:22:40 -07:00
Nick Kralevich
c97aba391d am 46f3ce87: Merge "remove init_shell"
* commit '46f3ce87d9a130924c763a245639331c6e1a5b28':
  remove init_shell
2014-10-23 22:31:21 +00:00
Stephen Smalley
86a39dd683 am d4731ad8: Remove -kernel -recovery from keystore_data_file neverallow.
* commit 'd4731ad8c78aade225aa7513332f546a603ddb53':
  Remove -kernel -recovery from keystore_data_file neverallow.
2014-10-23 22:30:13 +00:00
Nick Kralevich
5fad3d98de recovery: allow changing unlabeled symbolic links
Currently, recovery is allowed write access to the following three
file labels:

* system_file (directories, files, and symbolic links)
* exec_type (directories, files, and symbolic links)
* unlabeled (directory and files)

system_file is the default label on all files in /system. exec_type
is the attribute used to mark executables on /system.

The third file type, "unlabeled", refers to filesystem objects where
the label hasn't been set, or a label is set but isn't defined by the
currently loaded policy.

The current policy only allows unlabeled files or directories to
be modified. Symbolic links were accidentally excluded. This causes
problems when trying to fix up labels/permissions on unlabeled
symbolic links.

Allow unlabeled symbolic link modifications.

(cherrypicked from commit 683ac49d9d)

Bug: 18079773
Change-Id: I8e5c33602cdc38ec9a95b4e83f9ccbb06fe9da7c
2014-10-23 12:59:12 -07:00
Nick Kralevich
b519949df1 system_server: assert app data files never opened directly
Add a compile time assertion that app data files are never
directly opened by system_server. Instead, system_server always
expects files to be passed via file descriptors.

This neverallow rule will help prevent accidental regressions and
allow us to perform other security tightening, for example
bug 7208882 - Make an application's home directory 700

Bug: 7208882
Change-Id: I49c725982c4af0b8c76601b2a5a82a5c96df025d
2014-10-23 10:33:54 -07:00
Nick Kralevich
46f3ce87d9 Merge "remove init_shell" 2014-10-22 16:43:38 +00:00
Bill Yi
e269b48c69 Merge commit 'd0b1a44e5fba8284f1698d60aa25ed93221e8da5' into HEAD 2014-10-22 08:46:59 -07:00
Stephen Smalley
d4731ad8c7 Remove -kernel -recovery from keystore_data_file neverallow.
Aside from the keystore daemon itself, only init needs any access
to keystore_data_file (in order to create and potentially restorecon
/data/misc/keystore).  The exceptions for the kernel and recovery domains
are unnecessary; no allow rule permits this access in current policy.

Change-Id: I5cf6f29ec08174017ac8f5fb36fef166ce360ca0
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2014-10-22 11:13:17 -04:00
Nick Kralevich
f37d6b5713 remove init_shell
This domain was originally intended to be a place to hold rules for
all init.*.rc shell scripts. However, it's now recommended that every
init service have it's own SELinux domain, and the use of init_shell
is to be avoided.

Delete init_shell. No policy is using it anymore, and it's causing
confusion for people implementing device specific SELinux policy.

Bug: 18062250
Change-Id: I7c90851784b233443642ea69722f3281fd457621
2014-10-21 14:20:19 -07:00