Skip to content
Snippets Groups Projects
  1. Oct 31, 2014
  2. Oct 30, 2014
  3. Oct 29, 2014
    • Stephen Smalley's avatar
      Switch kernel and init to permissive_or_unconfined(). · a523aaca
      Stephen Smalley authored
      
      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: default avatarStephen Smalley <sds@tycho.nsa.gov>
      a523aaca
  4. Oct 28, 2014
  5. Oct 23, 2014
    • Nick Kralevich's avatar
      recovery: allow changing unlabeled symbolic links · 5fad3d98
      Nick Kralevich authored
      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 683ac49d)
      
      Bug: 18079773
      Change-Id: I8e5c33602cdc38ec9a95b4e83f9ccbb06fe9da7c
      5fad3d98
    • Nick Kralevich's avatar
      system_server: assert app data files never opened directly · b519949d
      Nick Kralevich authored
      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
      b519949d
  6. Oct 22, 2014
  7. Oct 21, 2014
    • Nick Kralevich's avatar
      remove init_shell · f37d6b57
      Nick Kralevich authored
      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
      f37d6b57
    • Stephen Smalley's avatar
      Remove -unconfineddomain from neverallow rules. · 0d08d472
      Stephen Smalley authored
      
      With the sepolicy-analyze neverallow checking, attribute
      expansion is performed against the device policy and therefore
      we do not want our neverallow rules to exempt domains from
      consideration based on an attribute (e.g. -unconfineddomain).
      Otherwise, device policy could pass the neverallow check just
      by adding more domains to unconfineddomain.  We could of course
      add a CTS test to check the list of unconfineddomains against
      a whitelist, but it seems desirable regardless to narrow these
      neverallow rules to only the specific domains required.
      
      There are three such neverallow rules in current policy: one
      on creating unlabeled files, one on accessing /dev/hw_random, and
      one on accessing a character device without a specific type.  The
      only domain in unconfineddomain that appears to have a legitimate
      need for any of these permissions is the init domain.  Replace
      -unconfineddomain with -init in these neverallow rules, exclude these
      permissions from unconfineddomain, and add these permissions to init if
      not already explicitly allowed.  auditallow accesses by init to files
      and character devices left in the generic device type so we can monitor
      what is being left there, although it is not necessarily a problem unless
      the file or device should be accessible to others.
      
      Change-Id: If6ee1b1a337c834971c6eb21dada5810608babcf
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      0d08d472
    • Nick Kralevich's avatar
      Merge "Allow adbd to write to /data/adb" · 06985b1d
      Nick Kralevich authored
      06985b1d
    • Nick Kralevich's avatar
      Allow adbd to write to /data/adb · 973877db
      Nick Kralevich authored
      adbd writes debugging information to /data/adb
      when persist.adb.trace_mask is set. Allow it.
      
      Bug: https://code.google.com/p/android/issues/detail?id=72895
      Change-Id: Ia5af09045e9f72a95325b429c30a5ae78e104bdc
      973877db
    • Stephen Smalley's avatar
      Remove block_device:blk_file access from fsck. · 3da1ffba
      Stephen Smalley authored
      
      Now that we have assigned specific types to userdata and cache
      block devices, we can remove the ability of fsck to run on other
      block devices.
      
      Change-Id: I8cfb3dc0e4ebe6b73346ff291ecb11397bb0c2d0
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      3da1ffba
  8. Oct 20, 2014
    • Nick Kralevich's avatar
      allow init swapon() · beb279c7
      Nick Kralevich authored
      swapon(2) requires write access to the underlying block device.
      Allow it.
      
      Addresses the following denial:
      
         avc:  denied  { write } for  pid=1 comm="init" name="zram0" dev="tmpfs" ino=6267 scontext=u:r:init:s0 tcontext=u:object_r:swap_block_device:s0 tclass=blk_file permissive=0
      
      Change-Id: Id1a4f51038d0b6ce7351294698a0ff146d6e4643
      beb279c7
    • Nick Kralevich's avatar
      add support for fsck.f2fs · 57a17d14
      Nick Kralevich authored
      The Nexus 9 uses f2fs for /data. Make sure to properly label
      /system/bin/fsck.f2fs so that the appropriate domain transition occurs.
      Add support for getattr on devpts, required for fsck.f2fs.
      
      Addresses the following denials:
      
        avc:  denied  { execute_no_trans } for  pid=172 comm="init" path="/system/bin/fsck.f2fs" dev="dm-0" ino=272 scontext=u:r:init:s0 tcontext=u:object_r:system_file:s0 tclass=file permissive=0
        avc:  denied  { getattr } for  pid=170 comm="fsck.f2fs" path="/dev/pts/0" dev="devpts" ino=3 scontext=u:r:fsck:s0 tcontext=u:object_r:devpts:s0 tclass=chr_file permissive=1
      
      Change-Id: I34b3f91374d1eb3fb4ba76abce14ff67db259f96
      57a17d14
  9. Oct 18, 2014
  10. Oct 17, 2014
    • Nick Kralevich's avatar
      Revert "Do not allow isolated_app to directly open app data files." · 44cb98a7
      Nick Kralevich authored
      This is causing the version of Chrome in Android's tree to crash. The
      version of Chrome in Android's tree does not have the following patch:
      https://codereview.chromium.org/630123003
      
      Until Chrome updates the version in Android's tree, we need to revert.
      
      Works around the following denials:
      
      audit(0.0:19): avc: denied { search } for name="com.android.chrome" dev="mmcblk0p28" ino=1474658 scontext=u:r:isolated_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir
      audit(0.0:20): avc: denied { getattr } for path="/data/data/com.android.chrome" dev="mmcblk0p28" ino=1474658 scontext=u:r:isolated_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir
      audit(0.0:21): avc: denied { getattr } for path="/data/data/com.android.chrome" dev="mmcblk0p28" ino=1474658 scontext=u:r:isolated_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir
      
      This reverts commit 669a9773.
      
      Bug: 18006219
      Change-Id: Id44137ec6a0dfe4a597b34ab3dad9e3feecc2a5e
      44cb98a7
  11. Oct 16, 2014
    • Stephen Smalley's avatar
      Exclude isolated_app from ptrace self. · e9623d8f
      Stephen Smalley authored
      
      Change-Id: I29136a805d2329806afc9d5d81af934a1803d8e0
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      e9623d8f
    • Nick Kralevich's avatar
      Fix compile time / CTS gps_data_files neverallow assertion · 38936af0
      Nick Kralevich authored
      Currently, zygote spawned apps are prohibited from modifying GPS
      data files. If someone tries to allow GPS access to any app domain,
      it generates a compile time / CTS exception.
      
      Relax the rules slightly for system_app. These apps run with UID=system,
      and shouldn't be banned from handling gps data files.
      
      This change doesn't add or remove any SELinux rules. Rather, it just
      relaxes a compile time assertion, allow partners to create SELinux
      rules allowing the access if they desire.
      
      (cherrypick from commit 480374e4)
      
      Bug: 18021422
      Change-Id: Iad0c6a3627efe129246e2c817f6f71d2735eba93
      38936af0
    • Mark Salyzyn's avatar
      logd: Add klogd · 664ef57b
      Mark Salyzyn authored
      Change-Id: Ib9bc89b05771a12c6bb9a25cf59ea51afd22ae15
      664ef57b
  12. Oct 15, 2014
    • Nick Kralevich's avatar
      maybe fix mac build. · 74bbf703
      Nick Kralevich authored
        1 warning generated.
        external/sepolicy/tools/sepolicy-analyze.c:446:27: error: implicit declaration of function 'isspace' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                while (p < end && isspace(*p))
                                ^
        1 error generated.
        make: *** [out/host/darwin-x86/obj32/EXECUTABLES/sepolicy-analyze_intermediates/sepolicy-analyze.o] Error 1
        make: *** Waiting for unfinished jobs....
      
      Change-Id: I250dcef7c726d5b66835dc51c057e472b801aa2c
      74bbf703
  13. Oct 14, 2014
  14. Oct 06, 2014
  15. Oct 03, 2014
  16. Oct 02, 2014
    • Stephen Smalley's avatar
      Label block devices created or accessed by vold with specific types. · 273d7ea4
      Stephen Smalley authored
      
      Assign a more specific type than block_device to all
      block devices created or accessed by vold.   Allow vold
      to set the context on the device nodes it creates.
      
      vold can create extra loop devices (/dev/block/loopN) and
      block devices for volumes it manages (/dev/block/vold/M:N).
      
      vold can read/write device mapper block devices (/dev/block/dm-N)
      created for encrypted volumes.
      
      vold can read/write metadata partitions used to store encryption metadata.
      The metadata_block_device type should be assigned in device-specific
      policy to the partition specified by the encryptable= mount option
      for the userata entry in the fstab.<board> file.
      
      This change does not remove the ability to create or read/write
      generic block_device devices by vold, so it should not break anything.
      It does add an auditallow statement on such accesses so that we can track
      remaining cases where we need to label such device nodes so that we can
      ultimately remove this access.
      
      Change-Id: Id3bea28f5958086716cd3db055bea309b3b5fa5a
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      273d7ea4
    • Nick Kralevich's avatar
      c6cb6ac4
    • Stephen Smalley's avatar
      Define specific block device types for system and recovery partitions. · 206b1a6c
      Stephen Smalley authored
      
      Define a specific block device type for system so that we can
      prevent raw writes to the system partition by anything other than
      recovery.
      
      Define a specific block device type for recovery so that we
      can prevent raw writes to the recovery partition by anything
      other than install_recovery or recovery.
      
      These types must be assigned to specific block device nodes
      via device-specific policy.  This change merely defines the types,
      adds allow rules so that nothing will break when the types are assigned,
      and adds neverallow rules to prevent adding further allow rules
      on these types.
      
      This change does not remove access to the generic block_device type
      from any domain so nothing should break even on devices without these
      type assignments.
      
      Change-Id: Ie9c1f6d632f6e9e8cbba106f07f6b1979d2a3c4a
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      206b1a6c
  17. Oct 01, 2014
    • Nick Kralevich's avatar
      isolated_app: remove app_data_file execute · 94f9ff87
      Nick Kralevich authored
      In commit ad891591, we allowed
      isolated processes to execute files from /data/data/APPNAME.
      
      I'm pretty sure all the necessary linker changes have been made
      so that this functionality isn't required anymore. Remove the
      allow rule.
      
      This is essentially a revert of ad891591.
      
      Change-Id: I1b073916f66f4965dfc53c0ea2b624bbb2fe8816
      94f9ff87
  18. Sep 30, 2014
    • Nick Kralevich's avatar
      eb5b76aa
    • Stephen Smalley's avatar
      Fix fsck-related denials with encrypted userdata. · cedee697
      Stephen Smalley authored
      
      Allow error reporting via the pty supplied by init.
      Allow vold to invoke fsck for checking volumes.
      
      Addresses denials such as:
      avc:  denied  { ioctl } for  pid=133 comm="e2fsck" path="/dev/pts/0" dev="devpts" ino=3 scontext=u:r:fsck:s0 tcontext=u:object_r:devpts:s0 tclass=chr_file
      
      avc: denied { execute } for pid=201 comm="vold" name="e2fsck" dev="mmcblk0p25" ino=98 scontext=u:r:vold:s0 tcontext=u:object_r:fsck_exec:s0 tclass=file
      
      These denials show up if you have encrypted userdata.
      
      Change-Id: Idc8e6f83a0751f17cde0ee5e4b1fbd6efe164e4c
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      cedee697
    • Stephen Smalley's avatar
      Mark asec_apk_file as mlstrustedobject. · 476c2078
      Stephen Smalley authored
      
      Resolves denials such as:
      avc:  denied  { write } for  pid=1546 comm="Binder_1" name="/" dev="dm-0" ino=2 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:asec_apk_file:s0 tclass=dir
      
      This is required to install a forward-locked app.
      
      Change-Id: I2b37a56d087bff7baf82c738896d9563f0ab4fc4
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      476c2078
  19. Sep 29, 2014
  20. Sep 28, 2014
    • Stephen Smalley's avatar
      Do not allow init to execute anything without changing domains. · 8a0c25ef
      Stephen Smalley authored
      
      Remove the ability of init to execute programs from / or /system
      without changing domains.  This forces all helper programs and
      services invoked by init to be assigned their own domain.
      
      Introduce separate domains for running the helper programs
      executed from the fs_mgr library by init.  This requires a domain
      for e2fsck (named fsck for generality) and a domain for running
      mkswap (named toolbox since mkswap is just a symlink to the toolbox
      binary and the domain transition occurs on executing the binary, not
      based on the symlink in any way).
      
      e2fsck is invoked on any partitions marked with the check mount
      option in the fstab file, typically userdata and cache but never
      system.  We allow it to read/write the userdata_block_device and
      cache_block_device types but also allow it to read/write the default
      block_device type until we can get the more specific types assigned
      in all of the device-specific policies.
      
      mkswap is invoked on any swap partition defined in the fstab file.
      We introduce a new swap_block_device type for this purpose, to be
      assigned to any such block devices in the device-specific policies,
      and only allow it to read/write such block devices.  As there seem to be
      no devices in AOSP with swap partitions in their fstab files, this does
      not appear to risk any breakage for existing devices.
      
      With the introduction of these domains, we can de-privilege init to
      only having read access to block devices for mounting filesystems; it
      no longer needs direct write access to such devices AFAICT.
      
      To avoid breaking execution of toolbox by system services, apps, or the shell,
      we allow all domains other than kernel and init the ability to
      run toolbox in their own domain.  This is broader than strictly required;
      we could alternatively only add it to those domains that already had
      x_file_perms to system_file but this would require a coordinated change
      with device-specific policy.
      
      Change-Id: Ib05de2d2bc2781dad48b70ba385577cb855708e4
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      8a0c25ef
    • Stephen Smalley's avatar
      Dependencies for new goldfish service domains. · 54e9bc45
      Stephen Smalley authored
      
      In order to support the new goldfish service domains in
      a change with the same Change-Id for the build project, we need
      the following changes in external/sepolicy:
      - /system/bin/logcat needs its own type so that it can be used as an
      entrypoint for the goldfish-logcat service.  A neverallow rule prevents
      us from allowing entrypoint to any type not in exec_type.
      - The config. and dalvik. property namespaces need to be labeled
      with something other than default_prop so that the qemu-props
      service can set them.  A neverallow rule prevents us from allowing
      qemu-props to set default_prop.
      
      We allow rx_file_perms to logcat_exec for any domain that
      was previously allowed read_logd() as many programs will read
      the logs by running logcat.  We do not do this for all domains
      as it would violate a neverallow rule on the kernel domain executing
      any file without transitioning to another domain, and as we ultimately
      want to apply the same restriction to the init domain (and possibly others).
      
      Change-Id: Idce1fb5ed9680af84788ae69a5ace684c6663974
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      54e9bc45
Loading