Skip to content
Snippets Groups Projects
  1. Dec 10, 2014
  2. 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
  3. Jul 15, 2014
  4. 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
  5. 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
      Remove execmod access to system_file and exec_type. · a893edae
      Stephen Smalley authored
      
      execmod is checked on attempts to make executable a file mapping
      that has been modified.  Typically this indicates a text relocation
      attempt.  As we do not ever allow this for any confined domain to
      system_file or exec_type, we should not need it for unconfineddomain
      either.
      
      Change-Id: I8fdc858f836ae0d2aa56da2abd7797fba9c258b1
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      a893edae
  6. Jun 20, 2014
  7. Jun 19, 2014
    • Stephen Smalley's avatar
      Remove write access to rootfs files. · 04b8a75c
      Stephen Smalley authored
      
      Remove write access to rootfs files from unconfineddomain and
      prevent adding it back via neverallow.  This is only applied to
      regular files, as we are primarily concerned with preventing
      writing to a file that can be exec'd and because creation of
      directories or symlinks in the rootfs may be required for mount
      point directories.
      
      Change-Id: If2c96da03f5dd6f56de97131f6ba9eceea328721
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      04b8a75c
    • 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
  8. Jun 17, 2014
  9. Jun 16, 2014
    • Stephen Smalley's avatar
      Restrict use of context= mount options. · 75e2ef92
      Stephen Smalley authored
      
      Prior to this change, the init and recovery domains were
      allowed unrestricted use of context= mount options to force
      all files within a given filesystem to be treated as having a
      security context specified at mount time.  The context= mount
      option can be used in device-specific fstab.<board> files
      to assign a context to filesystems that do not support labeling
      such as vfat where the default label of sdcard_external is not
      appropriate (e.g. /firmware on hammerhead).
      
      Restrict the use of context= mount options to types marked with the
      contextmount_type attribute, and then remove write access from
      such types from unconfineddomain and prohibit write access to such
      types via neverallow.  This ensures that the no write to /system
      restriction cannot be bypassed via context= mount.
      
      Change-Id: I4e773fadc9e11328d13a0acec164124ad6e840c1
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      75e2ef92
  10. Jun 07, 2014
  11. Jun 02, 2014
    • Riley Spahn's avatar
      Changed unconfined process policy to a whitelist. · 52dcc94d
      Riley Spahn authored
      Rewrote the process policy in external/sepolicy/unconfined.te
      from a blacklist to a whitelist to be more easily understood.
      There were previously 11 disallowed permissions and now there are
      19 allowed permissions.
      
      Change-Id: Ida4dc881c5fedc56980324774f40e09a9b8a830a
      52dcc94d
  12. May 30, 2014
    • Stephen Smalley's avatar
      Restrict /data/security and setprop selinux.reload_policy access. · 3235f61a
      Stephen Smalley authored
      
      Remove /data/security and setprop selinux.reload_policy access
      from unconfineddomain, and only add back what is needed to
      init (system_server already gets the required allow rules via
      the selinux_manage_policy macro).
      
      init (via init.rc post-fs-data) originally creates /data/security
      and may later restorecon it.  init also sets the property (also from
      init.rc post-fs-data) to trigger a reload once /data is mounted.
      The system_server (SELinuxPolicyInstallReceiver in particular) creates
      subdirectories under /data/security for updates, writes files to these
      subdirectories, creates the /data/security/current symlink to the update
      directory, and sets the property to trigger a reload when an update bundle
      is received.
      
      Add neverallow rules to ensure that we do not allow undesired access
      to security_file or security_prop.
      
      This is only truly meaningful if the support for /data/security policies
      is restored, but is harmless otherwise.
      
      Also drop the persist.mmac property_contexts entry; it was never used in
      AOSP, only in our tree (for middleware MAC) and is obsolete.
      
      Change-Id: I5ad5e3b6fc7abaafd314d31723f37b708d8fcf89
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      3235f61a
  13. May 29, 2014
    • Nick Kralevich's avatar
      Remove /system write from unconfined · 03ce5120
      Nick Kralevich authored
      Don't allow writes to /system from unconfined domains.
      /system is always mounted read-only, and no process should
      ever need to write there.
      
      Allow recovery to write to /system. This is needed to apply OTA
      images.
      
      Change-Id: I11aa8bd0c3b7f53ebe83806a0547ab8d5f25f3c9
      03ce5120
    • Stephen Smalley's avatar
      Protect /data/property. · ad0d0fc7
      Stephen Smalley authored
      
      /data/property is only accessible by root and is used by the init
      property service for storing persistent property values.  Create
      a separate type for it and only allow init to write to the directory
      and files within it.  Ensure that we do not allow access to other domains
      in future changes or device-specific policy via a neverallow rule.
      
      Change-Id: Iff556b9606c5651c0f1bba902e30b59bdd6f063a
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      ad0d0fc7
  14. May 28, 2014
  15. May 27, 2014
    • Stephen Smalley's avatar
      Remove setting /proc/self/attr/* from unconfined. · f853715d
      Stephen Smalley authored
      
      Change I6a2fb1279318625a80f3ea8e3f0932bdbe6df676 removed
      these permissions from domain.te and added them to specific domains
      as required.  Remove the permissions from unconfineddomain as well
      so that they are only allowed where explicitly allowed.  The earlier
      change already added the necessary permissions to init, kernel,
      and recovery so we do not need to add them here.
      
      Change-Id: Ifeb5438532a7525e64328e1c54b436e9b6f7fd3b
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      f853715d
  16. May 20, 2014
  17. May 09, 2014
    • Nick Kralevich's avatar
      Protect keystore's files. · cd905ec0
      Nick Kralevich authored
      Only keystore itself should be reading / writing it's files.
      Remove keystore file access from other SELinux domains, including
      unconfined. Add neverallow rules to protect against regressions.
      Allow init limited access to recurse into keystore's directory.
      
      Change-Id: I0bb5de7804f4314997c16fac18507933014bcadf
      cd905ec0
  18. Apr 03, 2014
  19. Mar 17, 2014
    • Stephen Smalley's avatar
      Remove MAC capabilities from unconfined domains. · 648c0d34
      Stephen Smalley authored
      
      Linux defines two capabilities for Mandatory Access Control (MAC)
      security modules, CAP_MAC_OVERRIDE (override MAC access restrictions)
      and CAP_MAC_ADMIN (allow MAC configuration or state changes).
      SELinux predates these capabilities and did not originally use them,
      but later made use of CAP_MAC_ADMIN as a way to control the ability
      to set security context values unknown to the currently loaded
      SELinux policy on files.  That facility is used in Linux for e.g.
      livecd creation where a file security context that is being set
      on a generated filesystem is not known to the build host policy.
      Internally, files with such labels are treated as having the unlabeled
      security context for permission checking purposes until/unless the
      context is later defined through a policy reload.
      
      CAP_MAC_OVERRIDE is never checked by SELinux, so it never needs
      to be allowed.  CAP_MAC_ADMIN is only checked if setting an
      unknown security context value; the only legitimate use I can see
      in Android is the recovery console, where a context may need to be set
      on /system that is not defined in the recovery policy.
      
      Remove these capabilities from unconfined domains, allow
      mac_admin for the recovery domain, and add neverallow rules.
      
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      
      (cherry picked from commit 04ee5dfb)
      
      Change-Id: I353fbe5da80f194cf1fd35053f91499ad0336692
      648c0d34
  20. Mar 10, 2014
    • Stephen Smalley's avatar
      Deduplicate neverallow rules on selinuxfs operations. · 853ffaad
      Stephen Smalley authored
      
      We already have neverallow rules for all domains about
      loading policy, setting enforcing mode, and setting
      checkreqprot, so we can drop redundant ones from netd and appdomain.
      Add neverallow rules to domain.te for setbool and setsecparam
      and exclude them from unconfined to allow fully eliminating
      separate neverallow rules on the :security class from anything
      other than domain.te.
      
      Change-Id: I0122e23ccb2b243f4c5376893e0c894f01f548fc
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      853ffaad
  21. Feb 12, 2014
  22. Feb 11, 2014
  23. Jan 30, 2014
    • Stephen Smalley's avatar
      Remove MAC capabilities from unconfined domains. · 04ee5dfb
      Stephen Smalley authored
      
      Linux defines two capabilities for Mandatory Access Control (MAC)
      security modules, CAP_MAC_OVERRIDE (override MAC access restrictions)
      and CAP_MAC_ADMIN (allow MAC configuration or state changes).
      SELinux predates these capabilities and did not originally use them,
      but later made use of CAP_MAC_ADMIN as a way to control the ability
      to set security context values unknown to the currently loaded
      SELinux policy on files.  That facility is used in Linux for e.g.
      livecd creation where a file security context that is being set
      on a generated filesystem is not known to the build host policy.
      Internally, files with such labels are treated as having the unlabeled
      security context for permission checking purposes until/unless the
      context is later defined through a policy reload.
      
      CAP_MAC_OVERRIDE is never checked by SELinux, so it never needs
      to be allowed.  CAP_MAC_ADMIN is only checked if setting an
      unknown security context value; the only legitimate use I can see
      in Android is the recovery console, where a context may need to be set
      on /system that is not defined in the recovery policy.
      
      Remove these capabilities from unconfined domains, allow
      mac_admin for the recovery domain, and add neverallow rules.
      
      Change-Id: Ief673e12bc3caf695f3fb67cabe63e68f5f58150
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      04ee5dfb
  24. Jan 27, 2014
    • Nick Kralevich's avatar
      Remove transition / dyntransition from unconfined · fed8a2a4
      Nick Kralevich authored
      Require all domain transitions or dyntransitions to be
      explicitly specified in SELinux policy.
      
      healthd: Remove healthd_exec / init_daemon_domain().
      Healthd lives on the rootfs and has no unique file type.
      It should be treated consistent with other similar domains.
      
      Change-Id: Ief3c1167379cfb5383073fa33c9a95710a883b29
      fed8a2a4
  25. Jan 13, 2014
  26. Jan 10, 2014
  27. Jan 08, 2014
  28. Jan 04, 2014
    • Nick Kralevich's avatar
      Don't allow zygote init:binder call · a730e50b
      Nick Kralevich authored
      init can't handle binder calls. It's always incorrect
      to allow init:binder call, and represents a binder call
      to a service without an SELinux domain. Adding this
      allow rule was a mistake; the dumpstate SELinux domain didn't
      exist at the time this rule was written, and dumpstate was
      running under init's domain.
      
      Add a neverallow rule to prevent the reintroduction of
      this bug.
      
      Change-Id: I78d35e675fd142d880f15329471778c18972bf50
      a730e50b
  29. Dec 09, 2013
    • Stephen Smalley's avatar
      Restrict mapping low memory. · e6a7b37d
      Stephen Smalley authored
      
      Label /proc/sys/vm/mmap_min_addr with proc_security to prevent
      writing it by any domain other than init.  Also remove memprotect
      mmap_zero permission from unconfineddomain so that it cannot pass
      the SELinux check over mapping low memory.
      
      Change-Id: Idc189feeb325a4aea26c93396fd0fa7225e79586
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      e6a7b37d
    • Stephen Smalley's avatar
      Restrict ptrace access by debuggerd and unconfineddomain. · 95e0842e
      Stephen Smalley authored
      
      Remove init, ueventd, watchdogd, healthd and adbd from the set of
      domains traceable by debuggerd.  bionic/linker/debugger.cpp sets up
      handlers for all dynamically linked programs in Android but this
      should not apply for statically linked programs.
      
      Exclude ptrace access from unconfineddomain.
      
      Prohibit ptrace access to init via neverallow.
      
      Change-Id: I70d742233fbe40cb4d1772a4e6cd9f8f767f2c3a
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      95e0842e
Loading