Skip to content
Snippets Groups Projects
  1. Nov 01, 2018
    • Nick Kralevich's avatar
      tun_device: enforce ioctl restrictions · 619c1ef2
      Nick Kralevich authored
      Require all SELinux domains which have permission to perform ioctls on
      /dev/tun explicitly specify what ioctls they perform. Only allow the
      safe defaults FIOCLEX and FIONCLEX, which are alternate, uncommon ways
      to set and unset the O_CLOEXEC flag.
      
      Remove app's ability to issue *any* ioctls on /dev/tun, period. Add
      neverallow assertions (compile time assertion + CTS test) to prevent
      regressions.
      
      Limit system_server's ability to perform ioctls on /dev/tun to FIOCLEX,
      FIONCLEX, TUNGETIFF, and TUNSETIFF. Testing and source code examination
      shows that only TUNGETIFF and TUNSETIFF are used by system_server.
      
      The goal of this change is to put SELinux ioctl controls in place for
      /dev/tun, so we don't have to maintain the custom kernel patch at
      https://android.googlesource.com/kernel/common/+/11cee2be0c2062ba88f04eb51196506f870a3b5d%5E%21
      
      Delete the neverallow assertion in isolated_app.te. This is already
      covered by the assertion present in app_neverallows.te.
      
      Test: cts-tradefed run cts -m CtsHostsideNetworkTests -t com.android.cts.net.HostsideVpnTests
      Test: cts-tradefed run cts -m CtsHostsideNetworkTests
      Test: cts-tradefed run cts -m CtsNetTestCases
      Bug: 111560739
      Bug: 111560570
      Change-Id: Ibe1c3a9e880db0bee438535554abdbc6d84eec45
      619c1ef2
    • Mark Salyzyn's avatar
      fastboot: /mnt/scratch refined access on userdebug · 33442f57
      Mark Salyzyn authored
      Already has permissions to remove the scratch partition, but to allow
      more refined cleansing (eg: just remove vendor override), need the
      ability to mount and scrub overlay directories.
      
      Test: manual
      Bug: 117605276
      Change-Id: Ibc272c0aa7ce207280023912f5f119ccf5079a7f
      33442f57
  2. Oct 31, 2018
    • Nick Kralevich's avatar
      Transient SELinux domain for system_server JIT · caf42d61
      Nick Kralevich authored
      Create a transient SELinux domain where system_server can perform
      certain JIT setup. The idea is that system_server will start in the
      system_server_startup domain, setup certain JIT pages, then perform a
      one-way transition into the system_server domain. From that point,
      further JITing operations are disallowed.
      
      Bug: 62356545
      Test: device boots, no permission errors
      Change-Id: Ic55b2cc5aba420ebcf62736622e08881a4779004
      caf42d61
  3. Oct 26, 2018
    • Tri Vo's avatar
      same_process_hal_file: access to individual coredomains · 90cf5a7f
      Tri Vo authored
      Remove blanket coredomain access to same_process_hal_file in favor of
      granular access. This change takes into account audits from go/sedenials
      (our internal dogfood program)
      
      Bug: 37211678
      Test: m selinux_policy
      Change-Id: I5634fb65c72d13007e40c131a600585a05b8c4b5
      90cf5a7f
  4. Oct 22, 2018
  5. Oct 19, 2018
    • Tri Vo's avatar
      Reland "Neverallow vendor code access to files on /system." · e6b1a4ca
      Tri Vo authored
      What changed:
      - Tightening neverallow forbidding vendor execution access in /system.
      In it's current form the neverallow is loose because not all executables
      have exec_type attribute, e.g. almost everything in /system/bin/. This
      change tightens up the neverallow by instead targeting system_file_type
      attribute, which must be applied to all files in /system.
      - Adding a general neverallow forbidding all access to files in /system
      (bar exceptions)
      
      TODOs:
      - Remove loopholes once Treble violations are fixed across all internal
      build targets.
      
      Bug: 111243627
      Test: m selinux_policy; build-only change
      Change-Id: I150195756c0c3258904c3da0812bbd942ea2f229
      e6b1a4ca
    • Pavel Grafov's avatar
      Revert "Neverallow vendor code access to files on /system." · 10b250df
      Pavel Grafov authored
      This reverts commit c855629e.
      
      Reason for revert: breaks builds for some devices in master
      
      Change-Id: I02c0967d6607ef0173b4188c06d2e781c3c93f4b
      10b250df
  6. Oct 18, 2018
    • Nick Kralevich's avatar
      start enforcing ioctl restrictions on blk_file · 4c8eaba7
      Nick Kralevich authored
      Start enforcing the use of ioctl restrictions on all Android block
      devices. Domains which perform ioctls on block devices must be explicit
      about what ioctls they issue. The only ioctls allowed by default are
      BLKGETSIZE64, BLKSSZGET, FIOCLEX, and FIONCLEX.
      
      Test: device boots and no problems.
      Change-Id: I1195756b20cf2b50bede1eb04a48145a97a35867
      4c8eaba7
    • Nick Kralevich's avatar
      Allow TCGETS on pipes (fifo_file) · 67900089
      Nick Kralevich authored
      Allow a process to determine if a fifo_file (aka pipe, created from the
      pipe() or pipe2() syscall) is a tty.
      
      Addresses the following denials:
      
      type=1400 audit(0.0:1307): avc: denied { ioctl } for comm="ls" path="pipe:[213117]" dev="pipefs" ino=213117 ioctlcmd=5401 scontext=u:r:hal_dumpstate_impl:s0 tcontext=u:r:hal_dumpstate_impl:s0 tclass=fifo_file permissive=0
      type=1400 audit(0.0:22): avc: denied { ioctl } for comm="sh" path="pipe:[54971]" dev="pipefs" ino=54971 ioctlcmd=5401 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:r:untrusted_app_27:s0:c512,c768 tclass=fifo_file permissive=0 app=com.zhihu.android
      type=1400 audit(0.0:237): avc: denied { ioctl } for comm="sh" path="pipe:[56997]" dev="pipefs" ino=56997 ioctlcmd=5401 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:r:untrusted_app_25:s0:c512,c768 tclass=fifo_file permissive=0 app=fm.qingting.qtradio
      
      Test: policy compiles and device builds.
      Change-Id: Ic4c6441d0ec33de8cda3f13ff529e98374897364
      67900089
  7. Oct 17, 2018
    • Tri Vo's avatar
      Neverallow vendor code access to files on /system. · c855629e
      Tri Vo authored
      What changed:
      - Tightening neverallow forbidding vendor execution access in /system.
      In it's current form the neverallow is loose because not all executables
      have exec_type attribute, e.g. almost everything in /system/bin/. This
      change tightens up the neverallow by instead targeting system_file_type
      attribute, which must be applied to all files in /system.
      - Adding a general neverallow forbidding all access to files in /system
      (bar exceptions)
      
      TODOs:
      - Remove loopholes once Treble violations are fixed across all internal
      build targets.
      
      Bug: 111243627
      Test: m selinux_policy; build-only change
      Change-Id: Ic8d71c8d139cad687ad7d7c9db7111240475f175
      c855629e
    • Nick Kralevich's avatar
      more ioctl work · 8ee8e263
      Nick Kralevich authored
      Add a neverallow rule requiring fine-grain ioctl filtering for most file
      and socket object classes. Only chr_file and blk_file are excluded. The
      goal is to ensure that any file descriptor which supports ioctl commands
      uses a whitelist.
      
      Further refine the list of file / socket objects which require ioctl
      filtering. The previous ioctl filtering did not cover the following:
      
      1) ioctls on /proc/PID files
      2) ioctls on directories in /dev
      3) PDX unix domain sockets
      
      Add FIONCLEX to the list of globally safe ioctls. FIOCLEX and FIONCLEX
      are alternate, uncommon ways to set the O_CLOEXEC flag on a file
      descriptor, which is a harmless operation.
      
      Test: device boots and no problems.
      Change-Id: I6ba31fbe2f21935243a344d33d67238d72a8e618
      8ee8e263
    • Dario Freni's avatar
      Allow apexd to create symlink in /apex. · bab267a8
      Dario Freni authored
      Bug: 115710947
      Test: on device
      Change-Id: Ie712689d80fb829f16de70e865cac4f0ff4e9b35
      bab267a8
  8. Oct 16, 2018
  9. Oct 15, 2018
    • Chong Zhang's avatar
      add media.codec.update service · 52fb3edb
      Chong Zhang authored
      Add a service in mediaswcodec to load updated codecs,
      and restrict it to userdebug/eng. Reuse existing
      mediaextractor_update_service since the codec update
      service is identical, this avoids adding a new one
      for now as we may not need the service anymore
      after switching to APEX.
      
      Bug: 111407413
      Bug: 117290290
      
      Change-Id: Ia75256f47433bd13ed819c70c1fb34ecd5d507b4
      52fb3edb
    • Tri Vo's avatar
      tcpdump: allow vendor access on userdebug builds. · 3a3a77d4
      Tri Vo authored
      Bug: 111243627
      Test: m selinux_policy
      Change-Id: I0bab79d1a3b7a8b5bf5d12ba2dc5ce46abea5332
      3a3a77d4
    • David Anderson's avatar
      Revert "Treat input files as public API." · c5b504da
      David Anderson authored
      This reverts commit 7a560eb4.
      
      Reason for revert: build bustage
      
      Change-Id: Iba0ba7a899dca865129a9c715c5f60f8a6edcc2f
      c5b504da
    • Tri Vo's avatar
      Finalize cgroup permissions. · 235d4860
      Tri Vo authored
      Policy w.r.t to apps:
      - cgroup access from untrusted apps and priv app is neverallow'ed.
      - other apps (e.g. vendor apps) need to explicitly declare appropriate
      access rules to cgroups.
      
      Policy w.r.t native domains:
      - libcutils exports API to /dev/{cpuset, stune}/*. This API is used
      abundantly in native vendor code. So we are not going to limit non-app
      access to cgroup.
      
      Bug: 110043362
      Bug: 117666318
      Test: m selinux_policy, boot device
      Change-Id: I83aee21ca3e8941725c70706769ea9dbdc76b9c5
      235d4860
  10. Oct 13, 2018
  11. Oct 12, 2018
    • Nick Kralevich's avatar
      Allow more file ioctls · 6586fe31
      Nick Kralevich authored
      The shell script interpreter checks if file descriptors are ttys, which
      causes a bunch of denials. Allow the benign ioctl TCGETS. Addresses the
      following denials:
      
        type=1400 audit(0.0:321): avc: denied { ioctl } for comm="sh"
        path="/data/misc/perfprofd/perferr.txt" dev="sda13" ino=6817306
        ioctlcmd=5401 scontext=u:r:perfprofd:s0
        tcontext=u:object_r:perfprofd_data_file:s0 tclass=file permissive=0
      
        type=1400 audit(0.0:3189): avc: denied { ioctl } for comm="ps"
        path="/data/user_de/0/com.android.shell/files/bugreports/bugreport-XXXXXXXXX-MASTER-2018-10-11-16-52-40.tmp"
        dev="dm-2" ino=25546 ioctlcmd=0x5401 scontext=u:r:dumpstate:s0
        tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=0
      
        type=1400 audit(0.0:3004): avc: denied { ioctl } for comm="top"
        path="/data/user_de/0/com.android.shell/files/bugreports/bugreport-XXXXXXXXX-MASTER-2018-10-11-16-52-40.tmp"
        dev="dm-2" ino=25546 ioctlcmd=0x5401 scontext=u:r:dumpstate:s0
        tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=0
      
      Include the virtual sdcard when allowing F2FS specific sqlite ioctls,
      since apps write sqlite files to the virtual sdcard. Addresses the
      following denials:
      
        type=1400 audit(0.0:324): avc: denied { ioctl } for comm="amapLocManagerT"
        path="/storage/emulated/0/amap/openamaplocationsdk/alsn20170807.db"
        dev="sdcardfs" ino=3546650 ioctlcmd=f50c
        scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:sdcardfs:s0
        tclass=file permissive=0 app=com.xiaomi.hm.health
      
      Test: policy compiles.
      Change-Id: I7fc570f2bbf69485b1ee6e6b2d9a421639d29123
      6586fe31
    • Nick Kralevich's avatar
      move cgroup auditallow into userdebug_or_eng block · 186466e9
      Nick Kralevich authored
      By convention, auditallow statements are typically put into
      userdebug_or_eng blocks, to ensure we don't accidentally ship
      unnecessary audit rules. Let's do the same here.
      
      Test: policy compiles.
      Change-Id: Ib3eac94284eea3c1ae2f3dacddcb2eaeca95230e
      186466e9
  12. Oct 11, 2018
    • Chong Zhang's avatar
      add mediaswcodec service · bdbfff1b
      Chong Zhang authored
      Set up a new service for sw media codec services.
      
      Bug: 111407413
      
      Test: cts-tradefed run cts-dev --module CtsMediaTestCases --compatibility:module-arg CtsMediaTestCases:include-annotation:android.platform.test.annotations.RequiresDevice
      Change-Id: Ia1c6a9ef3f0c1d84b2be8756eb1853ffa0597f8e
      bdbfff1b
    • Tri Vo's avatar
      Constrain cgroups access. · f55c989d
      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.
      
      Changes from original aosp/692189 which was reverted:
      - There seem to be spurious denials from vendor-specific apps. So added
      back access from { appdomain -all_untrusted_apps -priv_app } to cgroup.
      Audit this access with intent to write explicit per-domain rules for it.
      
      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
      This reverts commit cacea25e.
      Change-Id: I05ab404f348a864e8409d811346c8a0bf49bc47a
      f55c989d
  13. Oct 10, 2018
    • Nick Kralevich's avatar
      enable ioctl filtering on other filesystem types · 6695c50d
      Nick Kralevich authored
      ebc3a1a3 enabled ioctl filtering on
      normal files and directories. However, no per-ioctl permissions were
      enforced for symbolic links, named pipes ("mkfifo"), or
      named sockets.
      
      Start enforcing fine-grain ioctl restrictions for symbolic links, named
      pipes, and named sockets.
      
      Motivation: Prevent FS_IOC_ENABLE_VERIFY and FS_IOC_MEASURE_VERITY from
      being usable on nonsensical filesystem objects and provide a layer of
      defense for kernel bugs.
      
      Test: Device boots and no obvious problem.
      Change-Id: Id81b496ab64f37a0918f3dfd8fa9aaa3227009cc
      6695c50d
    • 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
  14. 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
  15. Oct 08, 2018
  16. Oct 04, 2018
    • Martijn Coenen's avatar
      Add policy for apexd. · ac097ac4
      Martijn Coenen authored
      apexd is a new daemon for managing APEX packages installed
      on the device. It hosts a single binder service, "apexservice".
      
      Bug: 112455435
      Test: builds, binder service can be registered,
            apexes can be accessed, verified and mounted
      Change-Id: I634ad100f10b2edcd9a9c0df0d33896fa5d4ed97
      ac097ac4
  17. 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
    • Nick Kralevich's avatar
      Label /system/usr/share/zoneinfo differently · ff1c765f
      Nick Kralevich authored
      /system/usr/share/zoneinfo is currently labeled zoneinfo_data_file,
      a label shared with /data/misc/zoneinfo. However, each of these
      directory locations has different security characteristics. In
      particular, the files in /system/usr/share/zoneinfo must never be
      writable, whereas /data/misc/zoneinfo may be written to by system_server.
      Reusing the same label hides these different security characteristics.
      
      Create a separate label for /system/usr/share/zoneinfo.
      
      Test: Device boots and no obvious problems.
      Change-Id: I8cf16ff038b06b38f77388e546d9b7a6865f7879
      ff1c765f
  18. Sep 23, 2018
    • Jeff Vander Stoep's avatar
      Further lock down app data · 0b67bb88
      Jeff Vander Stoep authored
      Assert that only apps and installd may open private app files.
      
      Remove "open" permission for mediaserver/vold and remove their
      neverallow exemption.
      
      Test: verify no related audit messages in the logs.
      Test: build
      Fixes: 80300620
      Fixes: 80418809
      Bug: 80190017
      Change-Id: If0c1862a273af1fedd8898f334c9b0aa6b9be728
      0b67bb88
  19. Sep 20, 2018
    • Tri Vo's avatar
      More granular vendor access to /system files. · 5c1fe61e
      Tri Vo authored
      This change limits global access to /system files down to:
      /system/bin/linker*
      /system/lib[64]/*
      /system/etc/ld.config*
      /system/etc/seccomp_policy/*
      /system/etc/security/cacerts/*
      /system/usr/share/zoneinfo/*
      
      Bug: 111243627
      Test: boot device, browse internet without denials to system_* types.
      Test: VtsHalDrmV1_{1, 0}TargetTest without denials
      Change-Id: I69894b29733979c2bc944ac80229e84de5d519f4
      5c1fe61e
  20. 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
  21. Sep 18, 2018
    • Tri Vo's avatar
      system_writes_mnt_vendor_violators for device launched before P. · ca4217e2
      Tri Vo authored
      In cases when a device upgrades to system-as-root from O to P, it needs a mount
      point for an already existing partition that is accessed by both system and
      vendor.
      
      Devices launching with P must not have /mnt/vendor accessible to system.
      
      Bug: 78598545
      Test: m selinx_policy
      Change-Id: Ia7bcde44e2b8657a7ad9e0d9bae7a7259f40936f
      ca4217e2
  22. 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
  23. Sep 13, 2018
    • Hridya Valsaraju's avatar
      Allow fastbootd to wipe metadata. · 073efc34
      Hridya Valsaraju authored
      Metadata needs to be erased as part of fastboot flashall -w.
      
      Test: fastboot erase metadata
      Bug: 113648914
      Change-Id: I38a0debd9face16cad9d9a13a48549f3f58652fa
      073efc34
  24. Sep 12, 2018
  25. Sep 11, 2018
    • Martijn Coenen's avatar
      Allow init to use binder. · a720d3d0
      Martijn Coenen authored
      But in a very restricted form:
      1) Nobody can initiate calls into init
      2) Nobody can transfer binder objects into init, except servicemanager
      
      Bug: 112684055
      Test: device boots
      Change-Id: Icfb218f2871e234284c74e096eccd7a2e786cf94
      a720d3d0
  26. Sep 06, 2018
    • Nick Kralevich's avatar
      dumpstate: remove JIT and /data execute · eef72d34
      Nick Kralevich authored
      Not needed for modern Android versions. These rules are really, really
      old.
      
      Test: "adb bugreport" continues to work
      Test: Generating a bugreport via key combo continues to work.
      Change-Id: Ibc1157fb36abd7fc701db3819474f25210a3cb5f
      eef72d34
Loading