Skip to content
Snippets Groups Projects
  1. Jan 18, 2017
    • Alex Klyubin's avatar
      1-arg variant of hal_impl_domain · b68cee25
      Alex Klyubin authored
      This improves readability and consistency for HAL implementation
      domains which have only one implementation.
      
      Test: No change to policy according to sesearch
      Test: No change to which types are associated with haldomain according to "sepolicy-analyze <sepolicy file> attribute haldomain"
      Bug: 34180936
      Change-Id: Ice599ea4971cdfbd8b835b1fd02ad1e14c7a0386
      b68cee25
  2. Jan 17, 2017
    • Alex Klyubin's avatar
      Group all HAL impls using haldomain attribute · f41d89eb
      Alex Klyubin authored
      This marks all HAL domain implementations with the haldomain attribute
      so that rules can be written which apply to all HAL implementations.
      
      This follows the pattern used for appdomain, netdomain and
      bluetoothdomain.
      
      Test: No change to policy according to sesearch.
      Bug: 34180936
      Change-Id: I0cfe599b0d49feed36538503c226dfce41eb65f6
      f41d89eb
  3. Jan 10, 2017
  4. Dec 28, 2016
  5. Dec 22, 2016
  6. Dec 21, 2016
    • Steven Moreland's avatar
      Remove ENABLE_TREBLE from sepolicy. · 52b75977
      Steven Moreland authored
      Enabling/disabling sepolicy based on ENABLE_TREBLE is not granular
      enough (ref: b/32978887 #4).
      
      Bug: 32978887
      Test: compiles, doesn't cause any additional denials on device. Nothing
      depends on these things I'm removing.
      Change-Id: I10acbde16e5e2093f2c9205ed79cd20caed7f44d
      52b75977
  7. Dec 15, 2016
    • Glen Kuhne's avatar
      hwbinder_use: allow for hwservicemanager callbacks. · 9147a238
      Glen Kuhne authored
      In order for hal clients to use IServiceManager::registerForNotifications,
      the hwservicemanager needs to be able to call into client processes.
      
      Test: WIP
      Bug: 33383725
      Change-Id: I59470e9cd5cbeafda010fedc0b91eeb41280e0a1
      9147a238
  8. Dec 08, 2016
    • dcashman's avatar
      Restore app_domain macro and move to private use. · 3e8dbf01
      dcashman authored
      app_domain was split up in commit: 2e00e637 to
      enable compilation by hiding type_transition rules from public policy.  These
      rules need to be hidden from public policy because they describe how objects are
      labeled, of which non-platform should be unaware.  Instead of cutting apart the
      app_domain macro, which non-platform policy may rely on for implementing new app
      types, move all app_domain calls to private policy.
      
      (cherry-pick of commit: 76035ea0)
      
      Bug: 33428593
      Test: bullhead and sailfish both boot. sediff shows no policy change.
      Change-Id: I4beead8ccc9b6e13c6348da98bb575756f539665
      3e8dbf01
  9. Dec 06, 2016
    • dcashman's avatar
      sepolicy: add version_policy tool and version non-platform policy. · 2e00e637
      dcashman authored
      In order to support platform changes without simultaneous updates from
      non-platform components, the platform and non-platform policies must be
      split.  In order to provide a guarantee that policy written for
      non-platform objects continues to provide the same access, all types
      exposed to non-platform policy are versioned by converting them and the
      policy using them into attributes.
      
      This change performs that split, the subsequent versioning and also
      generates a mapping file to glue the different policy components
      together.
      
      Test: Device boots and runs.
      Bug: 31369363
      Change-Id: Ibfd3eb077bd9b8e2ff3b2e6a0ca87e44d78b1317
      2e00e637
  10. Nov 28, 2016
    • Nick Kralevich's avatar
      Remove "eng" macro · d070b671
      Nick Kralevich authored
      Never used.
      
      Test: policy compiles.
      Change-Id: I0ce6c46bb05925a4b3eda83531b28f873b0c9b99
      d070b671
  11. Nov 23, 2016
  12. Nov 21, 2016
    • Nick Kralevich's avatar
      access_vectors: Remove unused permission definitions · 11dc03e5
      Nick Kralevich authored
      Description stolen from
      https://github.com/torvalds/linux/commit/42a9699a9fa179c0054ea3cf5ad3cc67104a6162
      
      Remove unused permission definitions from SELinux.
      Many of these were only ever used in pre-mainline
      versions of SELinux, prior to Linux 2.6.0.  Some of them
      were used in the legacy network or compat_net=1 checks
      that were disabled by default in Linux 2.6.18 and
      fully removed in Linux 2.6.30.
      
      Permissions never used in mainline Linux:
      file swapon
      filesystem transition
      tcp_socket { connectto newconn acceptfrom }
      node enforce_dest
      unix_stream_socket { newconn acceptfrom }
      
      Legacy network checks, removed in 2.6.30:
      socket { recv_msg send_msg }
      node { tcp_recv tcp_send udp_recv udp_send rawip_recv rawip_send dccp_recv dccp_send }
      netif { tcp_recv tcp_send udp_recv udp_send rawip_recv rawip_send dccp_recv dccp_send }
      
      Test: policy compiles and no boot errors (marlin)
      Change-Id: Idaef2567666f80db39c3e3cee70e760e1dac73ec
      11dc03e5
    • Jorge Lucangeli Obes's avatar
      Add WITH_DEXPREOPT_PIC to 'with_dexpreopt' SELinux macro. · 28994347
      Jorge Lucangeli Obes authored
      |WITH_DEXPREOPT_PIC = false| will still cause code to be loaded from
      /data.
      
      Bug: 32970029
      Test: On HiKey and Marlin:
      Test: Add |WITH_DEXPREOPT_PIC = false|, see SELinux denial.
      Test: Apply this CL, no SELinux denials.
      Change-Id: I0a1d39eeb4d7f75d84c1908b879d9ea1ccffba74
      28994347
  13. Nov 18, 2016
    • Jorge Lucangeli Obes's avatar
      Use with_dexpreopt macro for zygote execute permissions. · 84db84e6
      Jorge Lucangeli Obes authored
      When WITH_DEXPREOPT is set, the zygote does not need to execute
      dalvikcache_data_file objects.
      
      Bug: 32970029
      Test: Add policy line inside macro, build with and without WITH_DEXPREOPT.
      Test: HiKey builds, boots, no zygote denials.
      Change-Id: I4dace93e8044267232f0f26cfe427fc250d351fb
      84db84e6
  14. Oct 26, 2016
  15. Oct 19, 2016
  16. Oct 06, 2016
    • dcashman's avatar
      Split general policy into public and private components. · cc39f637
      dcashman authored
      Divide policy into public and private components.  This is the first
      step in splitting the policy creation for platform and non-platform
      policies.  The policy in the public directory will be exported for use
      in non-platform policy creation.  Backwards compatibility with it will
      be achieved by converting the exported policy into attribute-based
      policy when included as part of the non-platform policy and a mapping
      file will be maintained to be included with the platform policy that
      maps exported attributes of previous versions to the current platform
      version.
      
      Eventually we would like to create a clear interface between the
      platform and non-platform device components so that the exported policy,
      and the need for attributes is minimal.  For now, almost all types and
      avrules are left in public.
      
      Test: Tested by building policy and running on device.
      
      Change-Id: Idef796c9ec169259787c3f9d8f423edf4ce27f8c
      cc39f637
  17. Sep 14, 2016
  18. Sep 10, 2016
  19. Aug 29, 2016
  20. Aug 04, 2016
  21. Apr 23, 2016
    • Nick Kralevich's avatar
      reduce duplicate SELinux rules · 34936824
      Nick Kralevich authored
      When using domain_trans(init, foo_exec, foo), don't add the
      following rule:
      
        allow foo init:process sigchld;
      
      This is already allowed for all domains in domain.te:
      
        # Allow reaping by init.
        allow domain init:process sigchld;
      
      So adding it over and over again is redundant and bloats the
      policy. More specifically, when I run:
      
        sepolicy-analyze out/target/product/bullhead/root/sepolicy dups
      
      this change reduces the number of duplicate policy statements
      from 461 to 389.
      
      Change-Id: I8632e5649a54f63eb1f79ea6405c4b3f515f544c
      34936824
  22. Apr 15, 2016
    • Jeff Vander Stoep's avatar
      Further restrict socket ioctls available to apps · 32333536
      Jeff Vander Stoep authored
      (cherry picked from commit 6ba383c5)
      
      Restrict unix_dgram_socket and unix_stream_socket to a whitelist.
      Disallow all ioctls for netlink_selinux_socket and netlink_route_socket.
      
      Neverallow third party app use of all ioctls other than
      unix_dgram_socket, unix_stream_socket, netlink_selinux_socket,
      netlink_route_socket, tcp_socket, udp_socket and rawip_socket.
      
      Bug: 28171804
      Change-Id: Icfe3486a62fc2fc2d2abd8d4030a5fbdd0ab30ab
      32333536
  23. Apr 01, 2016
    • Nick Kralevich's avatar
      refine /data/misc/logd rules · 8a8770cd
      Nick Kralevich authored
      (cherry pick from commit 6937aa93)
      
      Followup to 121f5bfd.
      
      Move misc_logd_file neverallow rule from domain.te to logd.te,
      since the goal of the neverallow rule is to protect logd / logpersist
      files from other processes.
      
      Switch the misc_logd_file neverallow rule from using "rw_file_perms"
      to "no_rw_file_perms". The latter covers more cases of file
      modifications.
      
      Add more neverallow rules covering misc_logd_file directories.
      
      Instead of using not_userdebug_nor_eng(), modify the rules to be
      consistent with other highly constrained file types such as
      keystore_data_file or vold_data_file. See, for example,
      https://android-review.googlesource.com/144768
      
      To see the net effect of this change, you can use the following
      command line:
      
        sesearch --allow -t misc_logd_file -c file,dir,lnk_file \
        out/target/product/bullhead/root/sepolicy
      
      Before this change:
      
        # userdebug builds
        allow init misc_logd_file:dir { search setattr read create getattr write relabelfrom ioctl rmdir remove_name relabelto open add_name };
        allow init misc_logd_file:file { setattr read create write relabelfrom getattr relabelto unlink open };
        allow init misc_logd_file:lnk_file { setattr relabelfrom create getattr relabelto unlink };
        allow logd misc_logd_file:dir { search read lock getattr write ioctl remove_name open add_name };
        allow logd misc_logd_file:file { rename setattr read lock create getattr write ioctl unlink open append };
        allow shell misc_logd_file:dir { search read lock getattr ioctl open };
        allow shell misc_logd_file:file { read lock ioctl open getattr };
      
        # user builds
        allow init misc_logd_file:dir { search setattr read create getattr write relabelfrom ioctl rmdir remove_name relabelto open add_name };
        allow init misc_logd_file:file relabelto;
        allow init misc_logd_file:lnk_file { setattr relabelfrom create getattr relabelto unlink };
      
      After this change:
      
        # userdebug builds
        allow init misc_logd_file:dir { search setattr read create getattr ioctl relabelto open };
        allow init misc_logd_file:file { relabelto getattr };
        allow init misc_logd_file:lnk_file relabelto;
        allow logd misc_logd_file:dir { search read lock getattr write ioctl remove_name open add_name };
        allow logd misc_logd_file:file { rename setattr read lock create getattr write ioctl unlink open append };
        allow shell misc_logd_file:dir { search read lock getattr ioctl open };
        allow shell misc_logd_file:file { read lock ioctl open getattr };
      
        # user builds
        allow init misc_logd_file:dir { search setattr read create getattr ioctl relabelto open };
        allow init misc_logd_file:file { relabelto getattr };
        allow init misc_logd_file:lnk_file relabelto;
      
      Change-Id: I0b00215049ad83182f458b4b9e258289c5144479
      Bug: 27965066
      8a8770cd
  24. Mar 28, 2016
    • Nick Kralevich's avatar
      refine /data/misc/logd rules · 6937aa93
      Nick Kralevich authored
      Followup to 121f5bfd.
      
      Move misc_logd_file neverallow rule from domain.te to logd.te,
      since the goal of the neverallow rule is to protect logd / logpersist
      files from other processes.
      
      Switch the misc_logd_file neverallow rule from using "rw_file_perms"
      to "no_rw_file_perms". The latter covers more cases of file
      modifications.
      
      Add more neverallow rules covering misc_logd_file directories.
      
      Instead of using not_userdebug_nor_eng(), modify the rules to be
      consistent with other highly constrained file types such as
      keystore_data_file or vold_data_file. See, for example,
      https://android-review.googlesource.com/144768
      
      To see the net effect of this change, you can use the following
      command line:
      
        sesearch --allow -t misc_logd_file -c file,dir,lnk_file \
        out/target/product/bullhead/root/sepolicy
      
      Before this change:
      
        # userdebug builds
        allow init misc_logd_file:dir { search setattr read create getattr write relabelfrom ioctl rmdir remove_name relabelto open add_name };
        allow init misc_logd_file:file { setattr read create write relabelfrom getattr relabelto unlink open };
        allow init misc_logd_file:lnk_file { setattr relabelfrom create getattr relabelto unlink };
        allow logd misc_logd_file:dir { search read lock getattr write ioctl remove_name open add_name };
        allow logd misc_logd_file:file { rename setattr read lock create getattr write ioctl unlink open append };
        allow shell misc_logd_file:dir { search read lock getattr ioctl open };
        allow shell misc_logd_file:file { read lock ioctl open getattr };
      
        # user builds
        allow init misc_logd_file:dir { search setattr read create getattr write relabelfrom ioctl rmdir remove_name relabelto open add_name };
        allow init misc_logd_file:file relabelto;
        allow init misc_logd_file:lnk_file { setattr relabelfrom create getattr relabelto unlink };
      
      After this change:
      
        # userdebug builds
        allow init misc_logd_file:dir { search setattr read create getattr ioctl relabelto open };
        allow init misc_logd_file:file { relabelto getattr };
        allow init misc_logd_file:lnk_file relabelto;
        allow logd misc_logd_file:dir { search read lock getattr write ioctl remove_name open add_name };
        allow logd misc_logd_file:file { rename setattr read lock create getattr write ioctl unlink open append };
        allow shell misc_logd_file:dir { search read lock getattr ioctl open };
        allow shell misc_logd_file:file { read lock ioctl open getattr };
      
        # user builds
        allow init misc_logd_file:dir { search setattr read create getattr ioctl relabelto open };
        allow init misc_logd_file:file { relabelto getattr };
        allow init misc_logd_file:lnk_file relabelto;
      
      Change-Id: I0b00215049ad83182f458b4b9e258289c5144479
      6937aa93
  25. Mar 25, 2016
    • Mark Salyzyn's avatar
      init: logpersist access on debug · ab33c469
      Mark Salyzyn authored
      (cherry pick from commit 121f5bfd)
      
      03-25 09:31:22.996     1     1 W init    : type=1400 audit(0.0:8): \
        avc: denied { getattr } for path="/data/misc/logd/logcat.052" \
        dev="dm-2" ino=124778 scontext=u:r:init:s0 \
        tcontext=u:object_r:misc_logd_file:s0 tclass=file permissive=0
      . . .
      
      Introduced a new macro not_userdebug_nor_eng()
      
      Change-Id: I9c3a952c265cac096342493598fff7d41604ca45
      ab33c469
    • Mark Salyzyn's avatar
      init: logpersist access on debug · 121f5bfd
      Mark Salyzyn authored
      03-25 09:31:22.996     1     1 W init    : type=1400 audit(0.0:8): \
        avc: denied { getattr } for path="/data/misc/logd/logcat.052" \
        dev="dm-2" ino=124778 scontext=u:r:init:s0 \
        tcontext=u:object_r:misc_logd_file:s0 tclass=file permissive=0
      . . .
      
      Introduced a new macro not_userdebug_nor_eng()
      
      Change-Id: I9c3a952c265cac096342493598fff7d41604ca45
      121f5bfd
  26. Mar 11, 2016
  27. Jan 26, 2016
  28. Dec 08, 2015
    • Nick Kralevich's avatar
      Remove property read access for non-core properties · 5a570a4b
      Nick Kralevich authored
      Instead of allowing global read access to all properties,
      only allow read access to the properties which are part of
      core SELinux policy. Device-specific policies are no longer
      readable by default and need to be granted in device-specific
      policy.
      
      Grant read-access to any property where the person has write
      access. In most cases, anyone who wants to write a property
      needs read access to that property.
      
      Change-Id: I2bd24583067b79f31b3bb0940b4c07fc33d09918
      5a570a4b
  29. Dec 03, 2015
    • Tom Cherry's avatar
      Support fine grain read access control for properties · 949d7cbc
      Tom Cherry authored
      Properties are now broken up from a single /dev/__properties__ file into
      multiple files, one per property label.  This commit provides the
      mechanism to control read access to each of these files and therefore
      sets of properties.
      
      This allows full access for all domains to each of these new property
      files to match the current permissions of /dev/__properties__.  Future
      commits will restrict the access.
      
      Bug: 21852512
      
      Change-Id: Ie9e43968acc7ac3b88e354a0bdfac75b8a710094
      949d7cbc
  30. Sep 01, 2015
    • Jeff Vander Stoep's avatar
      system_server.te: remove policy load permissions · 0243e5cf
      Jeff Vander Stoep authored
      Remove system server's permission to dynamically update SELinux
      policy on the device.
      
      1) This functionality has never been used, so we have no idea if
      it works or not.
      
      2) If system_server is compromised, this functionality allows a
      complete bypass of the SELinux policy on the device. In particular,
      an attacker can force a regression of the following patch
        * https://android-review.googlesource.com/138510
      see also https://code.google.com/p/android/issues/detail?id=181826
      
      3) Dynamic policy update can be used to bypass neverallow protections
      enforced in CTS, by pushing a policy to the device after certification.
      Such an updated policy could bring the device out of compliance or
      deliberately introduce security weaknesses.
      
      Bug: 22885422
      Bug: 8949824
      Change-Id: I3c64d64359060561102e1587531836b69cfeef00
      0243e5cf
  31. Aug 24, 2015
  32. Jun 23, 2015
    • Nick Kralevich's avatar
      Allow /dev/klog access, drop mknod and __null__ access · 31d88a70
      Nick Kralevich authored
      Allow vold, healthd, slideshow, and watchdogd access to /dev/kmsg.
      These processes log to the kernel dmesg ring buffer, so they need
      write access to that file.
      
      Addresses the following denials:
      
          avc: denied { write } for pid=134 comm="watchdogd" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:watchdogd:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
          avc: denied { write } for pid=166 comm="healthd" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:healthd:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
          avc: denied { write } for pid=180 comm="vold" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:vold:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
      
      These denials were triggered by the change in
      https://android-review.googlesource.com/151209 . Prior to that change,
      any code which called klog_init would (unnecessarily) create the
      device node themselves, rather than using the already existing device
      node.
      
      Drop special /dev/__null__ handling from watchdogd. As of
      https://android-review.googlesource.com/148288 , watchdogd no longer
      creates it's own /dev/null device, so it's unnecessary for us
      to allow for it.
      
      Drop mknod from healthd, slideshow, and watchdogd. healthd and slideshow
      only needed mknod to create /dev/__kmsg__, which is now obsolete.
      watchdogd only needed mknod to create /dev/__kmsg__ and /dev/__null__,
      which again is now obsolete.
      
      (cherry picked from e2651972)
      
      Bug: 21242418
      Change-Id: If01c8001084575e7441253f0fa8b4179ae33f534
      31d88a70
  33. Jun 08, 2015
    • dcashman's avatar
      Remove service_manager_local_audit_domain. · 4b4b2b92
      dcashman authored
      service_manager_local_audit_domain was used to fine tune the service_manager
      auditallow rules when introducing the service_manager SELinux rules.  This is no
      longer needed.
      
      (cherry-pick of commit: eab26faa)
      
      Bug: 21656807
      Change-Id: Ia042a887e7bf9eb2a2b08b8d831e68dfe6395f75
      4b4b2b92
    • dcashman's avatar
      Remove service_manager_local_audit_domain. · eab26faa
      dcashman authored
      service_manager_local_audit_domain was used to fine tune the service_manager
      auditallow rules when introducing the service_manager SELinux rules.  This is no
      longer needed.
      
      Bug: 21656807
      Change-Id: Ia042a887e7bf9eb2a2b08b8d831e68dfe6395f75
      eab26faa
    • Nick Kralevich's avatar
      Allow /dev/klog access, drop mknod and __null__ access · e2651972
      Nick Kralevich authored
      Allow vold, healthd, slideshow, and watchdogd access to /dev/kmsg.
      These processes log to the kernel dmesg ring buffer, so they need
      write access to that file.
      
      Addresses the following denials:
      
          avc: denied { write } for pid=134 comm="watchdogd" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:watchdogd:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
          avc: denied { write } for pid=166 comm="healthd" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:healthd:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
          avc: denied { write } for pid=180 comm="vold" name="kmsg" dev="tmpfs" ino=9248 scontext=u:r:vold:s0 tcontext=u:object_r:kmsg_device:s0 tclass=chr_file permissive=0
      
      These denials were triggered by the change in
      https://android-review.googlesource.com/151209 . Prior to that change,
      any code which called klog_init would (unnecessarily) create the
      device node themselves, rather than using the already existing device
      node.
      
      Drop special /dev/__null__ handling from watchdogd. As of
      https://android-review.googlesource.com/148288 , watchdogd no longer
      creates it's own /dev/null device, so it's unnecessary for us
      to allow for it.
      
      Drop mknod from healthd, slideshow, and watchdogd. healthd and slideshow
      only needed mknod to create /dev/__kmsg__, which is now obsolete.
      watchdogd only needed mknod to create /dev/__kmsg__ and /dev/__null__,
      which again is now obsolete.
      
      Bug: 21242418
      Change-Id: If01c8001084575e7441253f0fa8b4179ae33f534
      e2651972
  34. May 14, 2015
  35. May 07, 2015
    • William Roberts's avatar
      Replace unix_socket_connect() and explicit property sets with macro · 2f5a6a96
      William Roberts authored
      
      A common source of mistakes when authoring sepolicy is properly
      setting up property sets. This is a 3 part step of:
      1. Allowing the unix domain connection to the init/property service
      2. Allowing write on the property_socket file
      3. Allowing the set on class property_service
      
      The macro unix_socket_connect() handled 1 and 2, but could be
      confusing for first time policy authors. 3 had to be explicitly
      added.
      
      To correct this, we introduce a new macros:
      set_prop(sourcedomain, targetprop)
      
      This macro handles steps 1, 2 and 3.
      
      No difference in sediff is expected.
      
      (cherrypicked from commit 625a3526)
      
      Change-Id: I630ba0178439c935d08062892990d43a3cc1239e
      Signed-off-by: default avatarWilliam Roberts <william.c.roberts@linux.intel.com>
      2f5a6a96
    • William Roberts's avatar
      Replace unix_socket_connect() and explicit property sets with macro · 625a3526
      William Roberts authored
      
      A common source of mistakes when authoring sepolicy is properly
      setting up property sets. This is a 3 part step of:
      1. Allowing the unix domain connection to the init/property service
      2. Allowing write on the property_socket file
      3. Allowing the set on class property_service
      
      The macro unix_socket_connect() handled 1 and 2, but could be
      confusing for first time policy authors. 3 had to be explicitly
      added.
      
      To correct this, we introduce a new macros:
      set_prop(sourcedomain, targetprop)
      
      This macro handles steps 1, 2 and 3.
      
      No difference in sediff is expected.
      
      Change-Id: I630ba0178439c935d08062892990d43a3cc1239e
      Signed-off-by: default avatarWilliam Roberts <william.c.roberts@linux.intel.com>
      625a3526
Loading