Skip to content
Snippets Groups Projects
  1. Oct 10, 2018
    • Nick Kralevich's avatar
      Move to ioctl whitelisting for plain files / directories · ebc3a1a3
      Nick Kralevich authored
      Remove kernel attack surface associated with ioctls on plain files. In
      particular, we want to ensure that the ioctls FS_IOC_ENABLE_VERITY and
      FS_IOC_MEASURE_VERITY are not exposed outside a whitelisted set of
      entities. However, it's straight forward enough to turn on ioctl
      whitelisting for everything, so we choose to do so.
      
      Test: policy compiles and device boots
      Test: device boots with data wipe
      Test: device boots without data wipe
      Change-Id: I545ae76dddaa2193890eeb1d404db79d1ffa13c2
      ebc3a1a3
    • Nick Kralevich's avatar
      Revert "Constrain cgroups access." · cacea25e
      Nick Kralevich authored
      This reverts commit 9899568f.
      
      Reason for revert: Reports of high numbers of SELinux denials
      showing up on the SELinux dashboard.
      
      Bug: 110043362
      Change-Id: Id8fc260c47ffd269ac2f15ff7dab668c959e3ab0
      cacea25e
  2. Oct 09, 2018
    • Tri Vo's avatar
      Constrain cgroups access. · 9899568f
      Tri Vo authored
      What changed:
      - Removed cgroup access from untrusted and priv apps.
      - Settings app writes to /dev/stune/foreground/tasks, so system_app domain
      retains access to cgroup.
      - libcutils exports API to /dev/{cpuset, stune}/*. This API seems to be used
      abundantly in native code. So added a blanket allow rule for (coredomain - apps)
      to access cgroups.
      - For now, only audit cgroup access from vendor domains. Ultimately, we want to
      either constrain vendor access to individual domains or, even better, remove
      vendor access and have platform manage cgroups exclusively.
      
      Bug: 110043362
      Test: adb shell setprop ro.config.per_app_memcg true, device correctly populates
      /dev/memcg on a per app basis on a device that supports that.
      Test: aosp_sailfish, wahoo boot without cgroup denials
      Change-Id: I9e441b26792f1edb1663c660bcff422ec7a6332b
      9899568f
  3. Sep 27, 2018
    • Nick Kralevich's avatar
      Introduce system_file_type · 5e37271d
      Nick Kralevich authored
      system_file_type is a new attribute used to identify files which exist
      on the /system partition. It's useful for allow rules in init, which are
      based off of a blacklist of writable files. Additionally, it's useful
      for constructing neverallow rules to prevent regressions.
      
      Additionally, add commented out tests which enforce that all files on
      the /system partition have the system_file_type attribute. These tests
      will be uncommented in a future change after all the device-specific
      policies are cleaned up.
      
      Test: Device boots and no obvious problems.
      Change-Id: Id9bae6625f042594c8eba74ca712abb09702c1e5
      5e37271d
  4. Sep 19, 2018
    • Benjamin Gordon's avatar
      sepolicy: grant dac_read_search to domains with dac_override · 342362ae
      Benjamin Gordon authored
      kernel commit 2a4c22426955d4fc04069811997b7390c0fb858e (fs: switch order
      of CAP_DAC_OVERRIDE and CAP_DAC_READ_SEARCH checks) swapped the order of
      dac_override and dac_read_search checks.  Domains that have dac_override
      will now generate spurious denials for dac_read_search unless they also
      have that permission.  Since dac_override is a strict superset of
      dac_read_search, grant dac_read_search to all domains that already have
      dac_override to get rid of the denials.
      
      Bug: 114280985
      Bug: crbug.com/877588
      Test: Booted on a device running 4.14.
      Change-Id: I5c1c136b775cceeb7f170e139e8d4279e73267a4
      342362ae
  5. Sep 14, 2018
    • Nick Kralevich's avatar
      Strengthen ptrace neverallow rules · 095fbea5
      Nick Kralevich authored
      Add additional compile time constraints on the ability to ptrace various
      sensitive domains.
      
      llkd: remove some domains which llkd should never ptrace, even on
      debuggable builds, such as kernel threads and init.
      
      crash_dump neverallows: Remove the ptrace neverallow checks because
      it duplicates other neverallow assertions spread throughout the policy.
      
      Test: policy compiles and device boots
      Change-Id: Ia4240d1ce7143b983bb048e046bb4729d0af5a6e
      095fbea5
  6. Aug 28, 2018
  7. Aug 02, 2018
    • Nick Kralevich's avatar
      Start partitioning off privapp_data_file from app_data_file · 23c9d91b
      Nick Kralevich authored
      Currently, both untrusted apps and priv-apps use the SELinux file label
      "app_data_file" for files in their /data/data directory. This is
      problematic, as we really want different rules for such files. For
      example, we may want to allow untrusted apps to load executable code
      from priv-app directories, but disallow untrusted apps from loading
      executable code from their own home directories.
      
      This change adds a new file type "privapp_data_file". For compatibility,
      we adjust the policy to support access privapp_data_files almost
      everywhere we were previously granting access to app_data_files
      (adbd and run-as being exceptions). Additional future tightening is
      possible here by removing some of these newly added rules.
      
      This label will start getting used in a followup change to
      system/sepolicy/private/seapp_contexts, similar to:
      
        -user=_app isPrivApp=true domain=priv_app type=app_data_file levelFrom=user
        +user=_app isPrivApp=true domain=priv_app type=privapp_data_file levelFrom=user
      
      For now, this newly introduced label has no usage, so this change
      is essentially a no-op.
      
      Test: Factory reset and boot - no problems on fresh install.
      Test: Upgrade to new version and test. No compatibility problems on
            filesystem upgrade.
      
      Change-Id: I9618b7d91d1c2bcb5837cdabc949f0cf741a2837
      23c9d91b
  8. Jul 31, 2018
    • Nick Kralevich's avatar
      Allow mmap for vendor_init · 99ceb07e
      Nick Kralevich authored
      vendor_init needs to touch a bunch of files. Forgotten within this set
      of permissions is the ability to mmap files.
      
      Addresses the following denial:
      
        avc:  denied  { map } for  pid=1167 comm="init" path="/system/etc/selinux/plat_file_contexts" dev="vda1" ino=1845 scontext=u:r:vendor_init:s0 tcontext=u:object_r:file_contexts_file:s0 tclass=file permissive=0
      
      While I'm here, add mmap() support to other areas where it's likely
      needed.
      
      Bug: 111742629
      Test: make -j80, ran emulator
      Change-Id: Icab00e45ae88f0d86be66d85a22e018af6ffcd75
      99ceb07e
  9. Jun 29, 2018
  10. Jun 28, 2018
  11. Jun 25, 2018
  12. Jun 13, 2018
    • Jiyong Park's avatar
      init is a dynamic executable · 90b21ee4
      Jiyong Park authored
      init is now a dynamic executable. So it has to be able to execute the
      dynamic linker (/system/bin/linker) and shared libraries (e.g.,
      /system/lib/libc.so). Furthermore, when in recovery mode, the files are
      all labeled as rootfs - because the recovery ramdisk does not support
      xattr, so files of type rootfs is allowed to be executed.
      
      Do the same for kernel and ueventd because they are executing the init
      executable.
      
      Bug: 63673171
      Test: `adb reboot recovery; adb devices` shows the device ID
      Change-Id: Ic6225bb8e129a00771e1455e259ff28241b70396
      90b21ee4
  13. May 04, 2018
    • Jeff Vander Stoep's avatar
      Start the process of locking down proc/net · 7a4af30b
      Jeff Vander Stoep authored
      Files in /proc/net leak information. This change is the first step in
      determining which files apps may use, whitelisting benign access, and
      otherwise removing access while providing safe alternative APIs.
      
      To that end, this change:
      * Introduces the proc_net_type attribute which will assigned to any
      new SELinux types in /proc/net to avoid removing access to privileged
      processes. These processes may be evaluated later, but are lower
      priority than apps.
      * Labels /proc/net/{tcp,tcp6,udp,udp6} as proc_net_vpn due to existing
      use by VPN apps. This may be replaced by an alternative API.
      * Audits all other proc/net access for apps.
      * Audits proc/net access for other processes which are currently
      granted broad read access to /proc/net but should not be including
      storaged, zygote, clatd, logd, preopt2cachename and vold.
      
      Bug: 9496886
      Bug: 68016944
      Test: Boot Taimen-userdebug. On both wifi and cellular: stream youtube
          navigate maps, send text message, make voice call, make video call.
          Verify no avc "granted" messages in the logs.
      Test: A few VPN apps including "VPN Monster", "Turbo VPN", and
      "Freighter". Verify no logspam with the current setup.
      Test: atest CtsNativeNetTestCases
      Test: atest netd_integration_test
      Test: atest QtaguidPermissionTest
      Test: atest FileSystemPermissionTest
      
      Change-Id: I7e49f796a25cf68bc698c6c9206e24af3ae11457
      Merged-In: I7e49f796a25cf68bc698c6c9206e24af3ae11457
      (cherry picked from commit 08731895)
      7a4af30b
  14. Apr 26, 2018
  15. Apr 20, 2018
    • Jeff Vander Stoep's avatar
      vendor_init: allow stat() of /data dir · 6f8d2628
      Jeff Vander Stoep authored
      avc: denied { getattr } for path="/data" scontext=u:r:vendor_init:s0
      tcontext=u:object_r:system_data_file:s0 tclass=dir permissive=1
      
      Bug: 78345561
      Test: build/boot device. Denial is gone.
      Change-Id: Ie858f1fe65aeb1845b00a5143c345e81aa2ec632
      6f8d2628
  16. Apr 18, 2018
    • Tom Cherry's avatar
      Allow vendor_init to access unencrypted_data_file · 620dc7f8
      Tom Cherry authored
      FBE needs to access these files to set up or verify encryption for
      directories during mkdir.
      
      Bug: 77850279
      Test: walleye + more restrictions continues to have FBE work
      Change-Id: I84e201436ce4531d36d1257d932c3e2e772ea05e
      (cherry picked from commit 18a28440)
      620dc7f8
  17. Apr 17, 2018
    • Tom Cherry's avatar
      Allow vendor_init to access unencrypted_data_file · 18a28440
      Tom Cherry authored
      FBE needs to access these files to set up or verify encryption for
      directories during mkdir.
      
      Bug: 77850279
      Test: walleye + more restrictions continues to have FBE work
      Change-Id: I84e201436ce4531d36d1257d932c3e2e772ea05e
      18a28440
  18. Apr 13, 2018
    • Tom Cherry's avatar
      Allow vendor_init to write to misc_block_device · 1f6018ea
      Tom Cherry authored
      Vendors may use this to write custom messages to their bootloader, and
      as the bootloader is under vendor control, this makes sense to allow.
      
      Bug: 77881566
      Test: build
      Merged-In: I78f80400e5f386cad1327a9209ee1afc8e334e56
      Change-Id: I78f80400e5f386cad1327a9209ee1afc8e334e56
      (cherry picked from commit db465285)
      1f6018ea
    • Tom Cherry's avatar
      Allow vendor_init to write to misc_block_device · db465285
      Tom Cherry authored
      Vendors may use this to write custom messages to their bootloader, and
      as the bootloader is under vendor control, this makes sense to allow.
      
      Bug: 77881566
      Test: build
      Change-Id: I78f80400e5f386cad1327a9209ee1afc8e334e56
      db465285
    • Jaekyun Seok's avatar
      Whitelist vendor-init-settable bluetooth_prop and wifi_prop · a11b16c9
      Jaekyun Seok authored
      Values of the following properties are set by SoC vendors on some
      devices including Pixels.
      - persist.bluetooth.a2dp_offload.cap
      - persist.bluetooth.a2dp_offload.enable
      - persist.vendor.bluetooth.a2dp_offload.enable
      - ro.bt.bdaddr_path
      - wlan.driver.status
      
      So they should be whitelisted for compatibility.
      
      Bug: 77633703
      Test: succeeded building and tested with Pixels
      Change-Id: Ib2b81bcc1fd70ddd571dc7fb2b923b576d62b7d5
      Merged-In: Ib2b81bcc1fd70ddd571dc7fb2b923b576d62b7d5
      (cherry picked from commit 224921d1)
      a11b16c9
    • Jaekyun Seok's avatar
      Whitelist vendor-init-settable bluetooth_prop and wifi_prop · 224921d1
      Jaekyun Seok authored
      Values of the following properties are set by SoC vendors on some
      devices including Pixels.
      - persist.bluetooth.a2dp_offload.cap
      - persist.bluetooth.a2dp_offload.enable
      - persist.vendor.bluetooth.a2dp_offload.enable
      - ro.bt.bdaddr_path
      - wlan.driver.status
      
      So they should be whitelisted for compatibility.
      
      Bug: 77633703
      Test: succeeded building and tested with Pixels
      Change-Id: Ib2b81bcc1fd70ddd571dc7fb2b923b576d62b7d5
      224921d1
  19. Apr 09, 2018
    • Max Bires's avatar
      Adding labeling for vendor security patch prop · 5cac1aa9
      Max Bires authored
      This will allow adb shell getprop ro.vendor.build.security_patch to
      properly return the correct build property, whereas previously it was
      offlimits due to lack of label.
      
      Test: adb shell getprop ro.vendor.build.security_patch successfully
      returns whatever VENDOR_SECURITY_PATCH is defined to be in the Android
      .mk files
      
      Change-Id: Ie8427738125fc7f909ad8d51e4b76558f5544d49
      5cac1aa9
  20. Mar 28, 2018
    • Jaekyun Seok's avatar
      Allow vendor-init-settable to persist.radio.multisim.config · 7d3bd8db
      Jaekyun Seok authored
      A default value of persist.radio.multisim.config can be set by SoC
      vendors, and so vendor-init-settable should be allowed to it.
      
      Bug: 73871799
      Test: succeeded building and tested with taimen
      Change-Id: Ie62b91e7e3d7e05425b742838417f1cab7b3fed4
      Merged-In: Ie62b91e7e3d7e05425b742838417f1cab7b3fed4
      (cherry picked from commit ac8c6e3d)
      7d3bd8db
  21. Mar 27, 2018
    • Jaekyun Seok's avatar
      Allow vendor-init-settable to persist.radio.multisim.config · ac8c6e3d
      Jaekyun Seok authored
      A default value of persist.radio.multisim.config can be set by SoC
      vendors, and so vendor-init-settable should be allowed to it.
      
      Bug: 73871799
      Test: succeeded building and tested with taimen
      Change-Id: Ie62b91e7e3d7e05425b742838417f1cab7b3fed4
      ac8c6e3d
  22. Feb 09, 2018
  23. Feb 01, 2018
  24. Jan 24, 2018
    • Tom Cherry's avatar
      Disallow vendor_init from accessing core_data_file_type · 564d5e39
      Tom Cherry authored
      Now that the vendor_init mechanism is in place, this SELinux
      restriction will disallow vendor init scripts from touching core data
      files as intended with Treble.
      
      Bug: 62875318
      Test: None
      Change-Id: Ifa50486c48551ba095d2ed8cc6570fc5040c172d
      564d5e39
  25. Jan 22, 2018
  26. Jan 10, 2018
    • Jaekyun Seok's avatar
      Whitelist exported platform properties · e4971454
      Jaekyun Seok authored
      This CL lists all the exported platform properties in
      private/exported_property_contexts.
      
      Additionally accessing core_property_type from vendor components is
      restricted.
      Instead public_readable_property_type is used to allow vendor components
      to read exported platform properties, and accessibility from
      vendor_init is also specified explicitly.
      
      Note that whitelisting would be applied only if
      PRODUCT_COMPATIBLE_PROPERTY is set on.
      
      Bug: 38146102
      Test: tested on walleye with PRODUCT_COMPATIBLE_PROPERTY=true
      Change-Id: I304ba428cc4ca82668fec2ddeb17c971e7ec065e
      e4971454
  27. Jan 02, 2018
  28. Dec 12, 2017
    • Marissa Wall's avatar
      Restrict access to uid_concurrent_*_time · 80ee23f7
      Marissa Wall authored
      Do not let apps read uid_concurrent_active_time and
      uid_concurrent_policy_time.
      
      b/68399339
      
      Test: Check that they can't be read from the shell
          without root permissions and system_server was able
          to read them
      
      Change-Id: I6f09ef608607cb9f4084ba403a1e7254b8c49a06
      80ee23f7
  29. Nov 21, 2017
    • Benjamin Gordon's avatar
      sepolicy: Add rules for non-init namespaces · 9b2e0cbe
      Benjamin Gordon authored
      In kernel 4.7, the capability and capability2 classes were split apart
      from cap_userns and cap2_userns (see kernel commit
      8e4ff6f228e4722cac74db716e308d1da33d744f). Since then, Android cannot be
      run in a container with SELinux in enforcing mode.
      
      This change applies the existing capability rules to user namespaces as
      well as the root namespace so that Android running in a container
      behaves the same on pre- and post-4.7 kernels.
      
      This is essentially:
        1. New global_capability_class_set and global_capability2_class_set
           that match capability+cap_userns and capability2+cap2_userns,
           respectively.
        2. s/self:capability/self:global_capability_class_set/g
        3. s/self:capability2/self:global_capability2_class_set/g
        4. Add cap_userns and cap2_userns to the existing capability_class_set
           so that it covers all capabilities.  This set was used by several
           neverallow and dontaudit rules, and I confirmed that the new
           classes are still appropriate.
      
      Test: diff new policy against old and confirm that all new rules add
            only cap_userns or cap2_userns;
            Boot ARC++ on a device with the 4.12 kernel.
      Bug: crbug.com/754831
      
      Change-Id: I4007eb3a2ecd01b062c4c78d9afee71c530df95f
      9b2e0cbe
  30. Oct 25, 2017
    • Tom Cherry's avatar
      add vendor_init.te · 621c24cb
      Tom Cherry authored
      First pass at adding vendor_init.te
      
      Bug: 62875318
      Test: boot sailfish with vendor_init
      Change-Id: I35cc9be324075d8baae866d6de4166c37fddac68
      621c24cb
Loading