Skip to content
Snippets Groups Projects
  1. Jun 02, 2015
    • Mark Salyzyn's avatar
      logd: logpersistd · 0d22c6ce
      Mark Salyzyn authored
      - Enable logpersistd to write to /data/misc/logd
      - Enable logpersistd to read from pstore to help complete any content
        lost by reboot disruption
      - Enable shell readonly ability logpersistd files in /data/misc/logd
      - Enable logcat -f when placed into logd context to act as a
        logpersistd (nee logcatd) agent, restrict access to run only in
        userdebug or eng
      
      Bug: 19608716
      Change-Id: I3209582bc796a1093c325c90068a48bf268e5ab5
      0d22c6ce
  2. Apr 29, 2015
  3. Apr 28, 2015
  4. Apr 27, 2015
  5. Apr 25, 2015
  6. Apr 24, 2015
  7. Apr 01, 2015
    • Jeff Sharkey's avatar
      Directory for vold to store private data. · 4423ecdb
      Jeff Sharkey authored
      Creates new directory at /data/misc/vold for storing key material
      on internal storage.  Only vold should have access to this label.
      
      Change-Id: I7f2d1314ad3b2686e29e2037207ad83d2d3bf465
      4423ecdb
  8. Mar 27, 2015
    • Paul Lawrence's avatar
      Adding e4crypt support · 38af1da1
      Paul Lawrence authored
      Add selinux rules to allow file level encryption to work
      
      Change-Id: I1e4bba23e99cf5b2624a7df843688fba6f3c3209
      38af1da1
  9. Mar 05, 2015
    • Sami Tolvanen's avatar
      Allow init to set up dm-verity · 35f537c7
      Sami Tolvanen authored
      Allow init to
      
       1. Access device mapper to set up dm-verity devices
      
          avc:  denied  { write } for  pid=156 comm="init" name="device-mapper" dev="tmpfs" ino=6229 scontext=u:r:init:s0 tcontext=u:object_r:dm_device:s0 tclass=chr_file permissive=0
      
       2. Access the metadata partition to load and store dm-verity state
      
          avc:  denied  { write } for  pid=1 comm="init" name="mmcblk0p25" dev="tmpfs" ino=6408 scontext=u:r:init:s0 tcontext=u:object_r:metadata_block_device:s0 tclass=blk_file permissive=0
      
       3. Read /sys/fs/pstore/console-ramoops to detect restarts triggered
          by dm-verity
      
          avc:  denied  { getattr } for  pid=1 comm="init" path="/sys/fs/pstore/console-ramoops" dev="pstore" ino=9911 scontext=u:r:init:s0 tcontext=u:object_r:pstorefs:s0 tclass=file permissive=0
      
      These can be reproduced using the following steps:
      
       1. Add fs_mgr flag verify to the system partition in fstab
      
       2. Add a device specific init.rc handler for the init action that
          calls the built-in command verity_load_state.
      
      Change-Id: Id8790ae4b204ca66e671eefd3820d649f1d1e7ba
      35f537c7
  10. Feb 28, 2015
  11. Feb 27, 2015
    • Nick Kralevich's avatar
      allow init tmpfs:dir relabelfrom · 543faccc
      Nick Kralevich authored
      When encrypting a device, or when an encrypted device boots,
      a tmpfs is mounted in place of /data, so that a pseudo filesystem
      exists to start system_server and related components. SELinux labels
      need to be applied to that tmpfs /data so the system boots
      properly.
      
      Allow init to relabel a tmpfs /data.
      
      Addresses the following denial:
      
      [    6.294896] type=1400 audit(29413651.850:4): avc:  denied  { relabelfrom } for  pid=1 comm="init" name="/" dev="tmpfs" ino=6360 scontext=u:r:init:s0 tcontext=u:object_r:tmpfs:s0 tclass=dir
      
      Steps to reproduce:
        1) Go into Settings > Security > Encrypt Phone
        2) Encrypt phone
        3) See denial
        4) reboot phone
        5) See denial on boot
      
      Bug: 19050686
      Change-Id: Ie57864fe1079d9164d5cfea44683a97498598e41
      543faccc
  12. Feb 26, 2015
    • Sami Tolvanen's avatar
      Allow init to execute /sbin/slideshow · 9d87c647
      Sami Tolvanen authored
      Add rules to allow /sbin/slideshow to access framebuffer and input
      devices at early stages of boot, and rules to allow init to execute
      the program (from init.rc using exec).
      
      Needed by changes from
        I58c79a7f3ac747eec0d73a10f018d3d8ade9df7d
      
      Change-Id: I1d5018feb7025853f0bf81651f497fef8c3a6ab0
      9d87c647
  13. Feb 25, 2015
    • Nick Kralevich's avatar
      Revert /proc/net related changes · 5cf3994d
      Nick Kralevich authored
      Revert the tightening of /proc/net access. These changes
      are causing a lot of denials, and I want additional time to
      figure out a better solution.
      
      Addresses the following denials (and many more):
      
        avc: denied { read } for comm="SyncAdapterThre" name="stats" dev="proc" ino=X scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file
        avc: denied { read } for comm="facebook.katana" name="iface_stat_fmt" dev="proc" ino=X scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file
        avc: denied { read } for comm="IntentService[C" name="if_inet6" dev="proc" ino=X scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file
        avc: denied { read } for comm="dumpstate" name="iface_stat_all" dev="proc" ino=X scontext=u:r:dumpstate:s0 tcontext=u:object_r:proc_net:s0 tclass=file
      
      This reverts commit 0f0324cc
      and commit 99940d1a
      
      Bug: 9496886
      Bug: 19034637
      Change-Id: I436a6e3638ac9ed49afbee214e752fe2b0112868
      5cf3994d
  14. Feb 23, 2015
  15. Feb 08, 2015
    • Nick Kralevich's avatar
      allow init fs_type:dir search · fcd86911
      Nick Kralevich authored
      We allow chmod/chown of files / directories by init, but don't allow
      init to search into subdirectories. Feels wrong.
      
      Addresses the following denial:
      
        avc:  denied  { search } for  pid=1 comm="init" name="/" dev="pstore" ino=5570 scontext=u:r:init:s0 tcontext=u:object_r:pstorefs:s0 tclass=dir permissive=1
      
      which results from the following init.rc statement:
      
        # pstore/ramoops previous console log
        mount pstore pstore /sys/fs/pstore
        chown system log /sys/fs/pstore/console-ramoops
        chmod 0440 /sys/fs/pstore/console-ramoops
        chown system log /sys/fs/pstore/pmsg-ramoops-0
        chmod 0440 /sys/fs/pstore/pmsg-ramoops-0
      
      Bug: 19050686
      Change-Id: I0528ecb17686891b66262de1f3c229cc68a56830
      fcd86911
  16. Feb 07, 2015
  17. Jan 14, 2015
    • Nick Kralevich's avatar
      remove /proc/net read access from domain.te · 99940d1a
      Nick Kralevich authored
      SELinux domains wanting read access to /proc/net need to
      explicitly declare it.
      
      TODO: fixup the ListeningPortsTest cts test so that it's not
      broken.
      
      Bug: 9496886
      Change-Id: Ia9f1214348ac4051542daa661d35950eb271b2e4
      99940d1a
  18. Jan 05, 2015
    • Nick Kralevich's avatar
      init.te: remove unactionable auditallow statements · 30707a45
      Nick Kralevich authored
      Commit 0d08d472 added two auditallow
      statements. The intented purpose of the auditallow statement was:
      
        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.
      
      As currently written, the auditallow rules aren't actionable. It's not
      a problem by itself for init to access a /dev file or chr_file.
      Rather, we care about when other domains access such files.
      
      Currently, this generates a number of (expected) audit statements on
      boot, which causes unnecessary confusion and makes people believe
      that something is broken.
      
      Remove the unactionable auditallow statements.
      
      Change-Id: Ibfe33976505a7dc3f8d15c9eb203c044a39da426
      30707a45
  19. Dec 24, 2014
    • Nick Kralevich's avatar
      init: allow rootfs symlink removal · 8809341c
      Nick Kralevich authored
      On the Nexus 9, init.rc creates the /vendor -> /system/vendor
      symlink, then a bit later removes the symlink, creates a
      proper directory, and mounts /vendor on the directory.
      
      The current permissive SELinux policy doesn't allow init to
      remove the /vendor symlink, which eventually causes the following
      errors:
      
        avc:  denied  { unlink } for  pid=136 comm="init" name="vendor" dev="rootfs" ino=6454 scontext=u:r:init:s0 tcontext=u:object_r:rootfs:s0 tclass=lnk_file permissive=1
        fs_mgr: Failed to mount an un-encryptable or wiped partition on/dev/block/platform/sdhci-tegra.3/by-name/VNR at /vendor options: (null) error: Too many symbolic links encountered
      
      There was an attempt to reorder some of these operations so
      we didn't have to create / delete the symlink, but it
      doesn't seem to have gone well.
      https://android.googlesource.com/platform/system/core/+/f67d6bd3c0fb41d167c675b9d2b5d377b6f38a74
      
      Change-Id: I4d01661d4228e44e18465fe16ce4a70fe2a83042
      8809341c
  20. Nov 10, 2014
    • Stephen Smalley's avatar
      Allow init to chown/chmod character devices. · 1c16abd3
      Stephen Smalley authored
      
      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: default avatarStephen Smalley <sds@tycho.nsa.gov>
      1c16abd3
  21. Oct 30, 2014
  22. 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
  23. Oct 21, 2014
    • 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
  24. 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
  25. 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
  26. Sep 02, 2014
  27. Aug 15, 2014
  28. Jul 17, 2014
    • Stephen Smalley's avatar
      Allow init to restorecon sysfs files. · 32915658
      Stephen Smalley authored
      The boot-time restorecon_recursive("/sys") occurs while still in
      the kernel domain, but init.rc files may nonetheless perform
      restorecon_recursive of parts of /sys created later and therefore
      require this permission.   Required for:
      https://android-review.googlesource.com/#/c/101800/
      
      
      
      Change-Id: I68dc2c6019a1f9deae3eec5c2f068365ce2372e5
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      32915658
    • Nick Kralevich's avatar
      lmkd: avoid locking libsigchain into memory · 57f1b89d
      Nick Kralevich authored
      https://android-review.googlesource.com/94851 added an LD_PRELOAD
      line to init.environ.rc.in. This has the effect of loading
      libsigchain.so into every process' memory space, regardless of
      whether it wants it or not.
      
      For lmkd, it doesn't need libsigchain, so it doesn't make any sense
      to load it and keep it locked in memory.
      
      Disable noatsecure for lmkd. This sets AT_SECURE=1, which instructs the
      linker to not honor security sensitive environment variables such
      as LD_PRELOAD. This prevents libsigchain.so from being loaded into
      lmkd's memory.
      
      (cherry picked from commit 8a5b28d2)
      
      Change-Id: I39baaf62058986d35ad43de708aaa3daf93b2df4
      57f1b89d
    • Nick Kralevich's avatar
      lmkd: avoid locking libsigchain into memory · 8a5b28d2
      Nick Kralevich authored
      https://android-review.googlesource.com/94851 added an LD_PRELOAD
      line to init.environ.rc.in. This has the effect of loading
      libsigchain.so into every process' memory space, regardless of
      whether it wants it or not.
      
      For lmkd, it doesn't need libsigchain, so it doesn't make any sense
      to load it and keep it locked in memory.
      
      Disable noatsecure for lmkd. This sets AT_SECURE=1, which instructs the
      linker to not honor security sensitive environment variables such
      as LD_PRELOAD. This prevents libsigchain.so from being loaded into
      lmkd's memory.
      
      Change-Id: I6378ba28ff3a1077747fe87c080e1f9f7ca8132e
      8a5b28d2
  29. Jul 15, 2014
  30. Jul 10, 2014
    • Nick Kralevich's avatar
      Remove domain:process from unconfined · a7c04dcd
      Nick Kralevich authored
      Prune down unconfined so it doesn't allow process access
      to all other domains. Use domain_trans() for transitions to
      seclabeled domains.
      
      Change-Id: I8e88a49e588b6b911e1f7172279455838a06091d
      a7c04dcd
  31. Jun 23, 2014
    • Stephen Smalley's avatar
      Align SELinux property policy with init property_perms. · fee49159
      Stephen Smalley authored
      
      Introduce a net_radio_prop type for net. properties that can be
      set by radio or system.
      Introduce a system_radio_prop type for sys. properties that can be
      set by radio or system.
      Introduce a dhcp_prop type for properties that can be set by dhcp or system.
      Drop the rild_prop vs radio_prop distinction; this was an early
      experiment to see if we could separate properties settable by rild
      versus other radio UID processes but it did not pan out.
      
      Remove the ability to set properties from unconfineddomain.
      Allow init to set any property.  Allow recovery to set ctl_default_prop
      to restart adbd.
      
      Change-Id: I5ccafcb31ec4004dfefcec8718907f6b6f3e0dfd
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      fee49159
    • Nick Kralevich's avatar
      unconfined: remove internet access · 0db95cce
      Nick Kralevich authored
      Don't allow unconfined domains to access the internet. Restrict
      internet functionality to domains which explicitly declare their
      use. Removing internet access from unconfined domains helps
      protect daemons from network level attacks.
      
      In unconfined.te, expand out socket_class_set, and explicitly remove
      tcp_socket, udp_socket, rawip_socket, packet_socket, and
      appletalk_socket. Remove name_bind, node_bind and name_connect rules,
      since they only apply to internet accessible rules.
      
      Add limited udp support to init.te. This is needed to bring up
      the loopback interface at boot.
      
      Change-Id: If756f3fed857f11e63a6c3a1a13263c57fdf930a
      0db95cce
    • Stephen Smalley's avatar
      Allow init to relabel rootfs files. · c626a882
      Stephen Smalley authored
      
      This is required for the restorecon /adb_keys in init.rc or
      for any other relabeling of rootfs files to more specific types on
      kernels that support setting security contexts on rootfs inodes.
      
      Addresses denials such as:
        avc: denied { relabelfrom } for comm="init" name="adb_keys" dev="rootfs" ino=1917 scontext=u:r:init:s0 tcontext=u:object_r:rootfs:s0 tclass=file permissive=0
      We do not need to prohibit relabelfrom of such files because our goal
      is to prevent writing to executable files, while relabeling the file
      to another type will take it to a non-executable (or non-writable) type.
      In contrast, relabelto must be prohibited by neverallow so that a
      modified file in a writable type cannot be made executable.
      
      Change-Id: I7595f615beaaa6fa524f3c32041918e197bfbebe
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      c626a882
  32. Jun 19, 2014
    • Stephen Smalley's avatar
      Remove execute_no_trans from unconfineddomain. · f3c3a1aa
      Stephen Smalley authored
      
      execute_no_trans controls whether a domain can execve a program
      without switching to another domain.  Exclude this permission from
      unconfineddomain, add it back to init, init_shell, and recovery for
      files in / and /system, and to kernel for files in / (to permit
      execution of init prior to setcon).  Prohibit it otherwise for the
      kernel domain via neverallow.  This ensures that if a kernel task
      attempts to execute a kernel usermodehelper for which no domain transition
      is defined, the exec will fail.
      
      Change-Id: Ie7b2349923672dd4f5faf7c068a6e5994fd0e4e3
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      f3c3a1aa
Loading