Skip to content
Snippets Groups Projects
  1. 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
  2. Jan 23, 2014
    • Nick Kralevich's avatar
      Support running adbd in the su domain. · 7d0f955e
      Nick Kralevich authored
      When adbd runs as root, it transitions into the
      su domain. Add the various rules to support this.
      
      This is needed to run the adbd and shell domains in
      enforcing on userdebug / eng devices without breaking
      developer workflows.
      
      Change-Id: Ib33c0dd2dd6172035230514ac84fcaed2ecf44d6
      7d0f955e
  3. Jan 16, 2014
    • Stephen Smalley's avatar
      Drop legacy device types. · d9b8ef43
      Stephen Smalley authored
      
      powervr_device is obsoleted by the more general gpu_device.
      akm_device and accelerometer_device are obsoleted by the more
      general sensors_device.
      
      We could also drop the file_contexts entries altogether and
      take them to device-specific policy (in this case, they all
      came from crespo, so that is obsolete for master).
      
      Change-Id: I63cef43b0d66bc99b80b64655416cc050f443e7d
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      d9b8ef43
  4. Jan 09, 2014
    • Stephen Smalley's avatar
      Remove domain init:unix_stream_socket connectto permission. · 39fd7818
      Stephen Smalley authored
      
      We do not want to permit connecting to arbitrary unconfined services
      left running in the init domain.  I do not know how this was originally
      triggered and thus cannot test that it is fixed.  Possible causes:
      - another service was left running in init domain, e.g. dumpstate,
      - there was a socket entry for the service in the init.rc file
      and the service was launched via logwrapper and therefore init did
      not know how to label the socket.
      
      The former should be fixed.  The latter can be solved either by
      removing use of logwrapper or by specifying the socket context
      explicitly in the init.rc file now.
      
      Change-Id: I09ececaaaea2ccafb7637ca08707566c1155a298
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      39fd7818
    • Stephen Smalley's avatar
      Allow access to unlabeled socket and fifo files. · 91c290b8
      Stephen Smalley authored
      
      Just use notdevfile_class_set to pick up all non-device file classes.
      
      Change-Id: Ib3604537ccfc25da67823f0f2b5d70b84edfaadf
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      91c290b8
    • Stephen Smalley's avatar
      Remove unlabeled execute access from domain, add to appdomain. · 959fdaaa
      Stephen Smalley authored
      
      Otherwise all domains can create/write files that are executable
      by all other domains.  If I understand correctly, this should
      only be necessary for app domains executing content from legacy
      unlabeled userdata partitions on existing devices and zygote
      and system_server mappings of dalvikcache files, so only allow
      it for those domains.
      
      If required for others, add it to the individual
      domain .te file, not for all domains.
      
      Change-Id: I6f5715eb1ecf2911e70772b9ab4e531feea18819
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      959fdaaa
  5. Jan 08, 2014
  6. Jan 07, 2014
  7. 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
  8. Jan 03, 2014
    • Stephen Smalley's avatar
      Address adb backup/restore denials. · c4021ceb
      Stephen Smalley authored
      
      Resolves the following denials seen during an adb backup and restore
      sequence.
      
      <5>[   90.247039] type=1400 audit(1388759567.693:16): avc:  denied  { getopt } for  pid=3503 comm="Thread-149" scontext=u:r:system_server:s0 tcontext=u:r:adbd:s0 tclass=unix_stream_socket
      <5>[   90.249176] type=1400 audit(1388759567.703:17): avc:  denied  { getopt } for  pid=2334 comm="app_process" scontext=u:r:shell:s0 tcontext=u:r:adbd:s0 tclass=unix_stream_socket
      
      Change-Id: I1f6f90f29eecc32ee692764b04b812988f099cde
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      c4021ceb
  9. Jan 02, 2014
    • Stephen Smalley's avatar
      Remove execmem permission from domain, add to appdomain. · ad7df7bb
      Stephen Smalley authored
      
      execmem permission controls the ability to make an anonymous
      mapping executable or to make a private file mapping writable
      and executable.  Remove this permission from domain (i.e.
      all domains) by default, and add it explicitly to app domains.
      It is already allowed in other specific .te files as required.
      There may be additional cases in device-specific policy where
      it is required for proprietary binaries.
      
      Change-Id: I902ac6f8cf2e93d46b3a976bc4dabefa3905fce6
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      ad7df7bb
  10. Dec 18, 2013
    • Stephen Smalley's avatar
      Confine shell domain in -user builds only. · 712ca0a4
      Stephen Smalley authored
      
      Confine the domain for an adb shell in -user builds only.
      The shell domain in non-user builds is left permissive.
      init_shell (shell spawned by init, e.g.  console service)
      remains unconfined by this change.
      Introduce a shelldomain attribute for rules common to all shell
      domains, assign it to the shell types, and add shelldomain.te for
      its rules.
      
      Change-Id: I01ee2c7ef80b61a9db151abe182ef9af7623c461
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      712ca0a4
  11. Dec 13, 2013
    • Nick Kralevich's avatar
      Label /data/misc/zoneinfo · 7466f9b6
      Nick Kralevich authored
      And allow any SELinux domain to read these timezone
      related files.
      
      Addresses the following denial:
      <5>[    4.746399] type=1400 audit(3430294.470:7): avc:  denied  { open } for  pid=197 comm="time_daemon" name="tzdata" dev="mmcblk0p28" ino=618992 scontext=u:r:time:s0 tcontext=u:object_r:system_data_file:s0 tclass=file
      
      Change-Id: Iff32465e62729d7aad8c79607848d89ce0aede86
      7466f9b6
  12. Dec 09, 2013
    • 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
  13. Dec 06, 2013
    • Stephen Smalley's avatar
      Allow kernel domain, not init domain, to set SELinux enforcing mode. · fea6e66f
      Stephen Smalley authored
      As per the discussion in:
      https://android-review.googlesource.com/#/c/71184/
      
      
      
      init sets the enforcing mode in its code prior to switching to
      the init domain via a setcon command in the init.rc file.  Hence,
      the setenforce permission is checked while still running in the
      kernel domain.  Further, as init has no reason to ever set the
      enforcing mode again, we do not need to allow setenforce to the
      init domain and this prevents reverting to permissive
      mode via an errant write by init later.  We could technically
      dontaudit the kernel setenforce access instead since the first
      call to setenforce happens while still permissive (and thus we
      never need to allow it in policy) but we allow it to more accurately
      represent what is possible.
      
      Change-Id: I70b5e6d8c99e0566145b9c8df863cc8a34019284
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      fea6e66f
    • Nick Kralevich's avatar
      Revert "Allow kernel domain, not init domain, to set SELinux enforcing mode." · 9e8b8d9f
      Nick Kralevich authored
      The build is broken. Reverting temporarily to fix breakage.
      
      libsepol.check_assertion_helper: neverallow on line 4758 violated by allow init kernel:security { setenforce };
      Error while expanding policy
      make: *** [out/target/product/mako/obj/ETC/sepolicy_intermediates/sepolicy] Error 1
      make: *** Waiting for unfinished jobs....
      
      
      This reverts commit bf12e225.
      
      Change-Id: I78a05756d8ce3c7d06e1d9d27e6135f4b352bb85
      9e8b8d9f
    • Stephen Smalley's avatar
      Allow kernel domain, not init domain, to set SELinux enforcing mode. · bf12e225
      Stephen Smalley authored
      As per the discussion in:
      https://android-review.googlesource.com/#/c/71184/
      
      
      
      init sets the enforcing mode in its code prior to switching to
      the init domain via a setcon command in the init.rc file.  Hence,
      the setenforce permission is checked while still running in the
      kernel domain.  Further, as init has no reason to ever set the
      enforcing mode again, we do not need to allow setenforce to the
      init domain and this prevents reverting to permissive
      mode via an errant write by init later.  We could technically
      dontaudit the kernel setenforce access instead since the first
      call to setenforce happens while still permissive (and thus we
      never need to allow it in policy) but we allow it to more accurately
      represent what is possible.
      
      Change-Id: I617876c479666a03167b8fce270c82a8d45c7cc6
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      bf12e225
    • Stephen Smalley's avatar
      Restrict the ability to set usermodehelpers and proc security settings. · 7adb999e
      Stephen Smalley authored
      
      Limit the ability to write to the files that configure kernel
      usermodehelpers and security-sensitive proc settings to the init domain.
      Permissive domains can also continue to set these values.
      
      The current list is not exhaustive, just an initial set.
      Not all of these files will exist on all kernels/devices.
      Controlling access to certain kernel usermodehelpers, e.g. cgroup
      release_agent, will require kernel changes to support and cannot be
      addressed here.
      
      Expected output on e.g. flo after the change:
      ls -Z /sys/kernel/uevent_helper /proc/sys/fs/suid_dumpable /proc/sys/kernel/core_pattern /proc/sys/kernel/dmesg_restrict /proc/sys/kernel/hotplug /proc/sys/kernel/kptr_restrict /proc/sys/kernel/poweroff_cmd /proc/sys/kernel/randomize_va_space /proc/sys/kernel/usermodehelper
      -rw-r--r-- root     root              u:object_r:usermodehelper:s0 uevent_helper
      -rw-r--r-- root     root              u:object_r:proc_security:s0 suid_dumpable
      -rw-r--r-- root     root              u:object_r:usermodehelper:s0 core_pattern
      -rw-r--r-- root     root              u:object_r:proc_security:s0 dmesg_restrict
      -rw-r--r-- root     root              u:object_r:usermodehelper:s0 hotplug
      -rw-r--r-- root     root              u:object_r:proc_security:s0 kptr_restrict
      -rw-r--r-- root     root              u:object_r:usermodehelper:s0 poweroff_cmd
      -rw-r--r-- root     root              u:object_r:proc_security:s0 randomize_va_space
      -rw------- root     root              u:object_r:usermodehelper:s0 bset
      -rw------- root     root              u:object_r:usermodehelper:s0 inheritable
      
      Change-Id: I3f24b4bb90f0916ead863be6afd66d15ac5e8de0
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      7adb999e
  14. Dec 05, 2013
    • Robert Craig's avatar
      Drop tegra specific label from policy. · b2547644
      Robert Craig authored
      This label was originally used for Motorola
      Xoom devices. nvmap is the tegra gpu memory
      manager and the various nvhost drivers are
      for tegra graphics related functionality,
      i.e. display serial interface, image signal
      processor, or media processing stuff.
      
      Only grouper and tilapia presently need this
      policy.
      
      Change-Id: I2a7000f69abf3185724d88d428e8237e0ca436ec
      b2547644
  15. Dec 02, 2013
  16. Nov 08, 2013
  17. Nov 06, 2013
  18. Oct 30, 2013
    • Nick Kralevich's avatar
      Move sysfs_devices_system_cpu to the central policy. · 967f39a6
      Nick Kralevich authored
      Every device has a CPU. This is not device specific.
      
      Allow every domain to read these files/directories.
      For unknown reasons, these files are accessed by A LOT
      of processes.
      
      Allow ueventd to write to these files. This addresses
      the following denials seen on mako:
      
      <5>[    4.935602] type=1400 audit(1383167737.512:4): avc:  denied  { read } for  pid=140 comm="ueventd" name="cpu0" dev="sysfs" ino=3163 scontext=u:r:ueventd:s0 tcontext=u:object_r:sysfs_devices_system_cpu:s0 tclass=dir
      <5>[    4.935785] type=1400 audit(1383167737.512:5): avc:  denied  { open } for  pid=140 comm="ueventd" name="cpu0" dev="sysfs" ino=3163 scontext=u:r:ueventd:s0 tcontext=u:object_r:sysfs_devices_system_cpu:s0 tclass=dir
      <5>[    4.935937] type=1400 audit(1383167737.512:6): avc:  denied  { search } for  pid=140 comm="ueventd" name="cpu0" dev="sysfs" ino=3163 scontext=u:r:ueventd:s0 tcontext=u:object_r:sysfs_devices_system_cpu:s0 tclass=dir
      <5>[    4.936120] type=1400 audit(1383167737.512:7): avc:  denied  { write } for  pid=140 comm="ueventd" name="uevent" dev="sysfs" ino=3164 scontext=u:r:ueventd:s0 tcontext=u:object_r:sysfs_devices_system_cpu:s0 tclass=file
      <5>[    4.936303] type=1400 audit(1383167737.512:8): avc:  denied  { open } for  pid=140 comm="ueventd" name="uevent" dev="sysfs" ino=3164 scontext=u:r:ueventd:s0 tcontext=u:object_r:sysfs_devices_system_cpu:s0 tclass=file
      
      Change-Id: I4766dc571762d8fae06aa8c26828c070b80f5936
      967f39a6
  19. Oct 08, 2013
    • William Roberts's avatar
      Start confining ueventd · 85c5fc21
      William Roberts authored
      * Keep ueventd in permissive
      * Drop unconfined macro to collect logs
      * Restore allow rules to current NSA maintained policy
      
      Change-Id: Ic4ee8e24ccd8887fed151ae1e4f197512849f57b
      85c5fc21
  20. Oct 03, 2013
    • Alex Klyubin's avatar
      Restrict access to /dev/hw_random to system_server and init. · 8d688315
      Alex Klyubin authored
      /dev/hw_random is accessed only by init and by EntropyMixer (which
      runs inside system_server). Other domains are denied access because
      apps/services should be obtaining randomness from the Linux RNG.
      
      Change-Id: Ifde851004301ffd41b2189151a64a0c5989c630f
      8d688315
  21. Sep 27, 2013
  22. Sep 17, 2013
    • Alex Klyubin's avatar
      1/2: Rename domain "system" to "system_server". · 1fdee11d
      Alex Klyubin authored
      This is a follow-up CL to the extraction of "system_app" domain
      from the "system" domain which left the "system" domain encompassing
      just the system_server.
      
      Since this change cannot be made atomically across different
      repositories, it temporarily adds a typealias "server" pointing to
      "system_server". Once all other repositories have been switched to
      "system_server", this alias will be removed.
      
      Change-Id: I90a6850603dcf60049963462c5572d36de62bc00
      1fdee11d
  23. Sep 13, 2013
  24. Sep 10, 2013
    • Alex Klyubin's avatar
      Permit writing to /dev/random and /dev/urandom. · a2477056
      Alex Klyubin authored
      Apps attempting to write to /dev/random or /dev/urandom currently
      succeed, but a policy violation is logged. These two Linux RNG
      devices are meant to be written to by arbitrary apps. Thus, there's
      no reason to deny this capability.
      
      Bug: 10679705
      
      Change-Id: Ife401f1dd2182889471eef7e90fcc92e96f9c4d6
      a2477056
  25. Aug 30, 2013
  26. Jul 16, 2013
  27. Jul 15, 2013
  28. Jul 14, 2013
    • Nick Kralevich's avatar
      untrusted_app.te / isolated_app.te / app.te first pass · 6634a108
      Nick Kralevich authored
      This is my first attempt at creating an enforcing SELinux domain for
      apps, untrusted_apps, and isolated_apps. Much of these rules are based on the
      contents of app.te as of commit 11153ef3
      with extensive modifications, some of which are included below.
      
      * Allow communication with netd/dnsproxyd, to allow netd to handle
        dns requests
      * Allow binder communications with the DNS server
      * Allow binder communications with surfaceflinger
      * Allow an app to bind to tcp/udp ports
      * Allow all domains to read files from the root partition, assuming
        the DAC allows access.
      
      In addition, I added a bunch of "neverallow" rules, to assert that
      certain capabilities are never added.
      
      This change has a high probability of breaking someone, somewhere.
      If it does, then I'm happy to fix the breakage, rollback this change,
      or put untrusted_app into permissive mode.
      
      Change-Id: I83f220135d20ab4f70fbd7be9401b5b1def1fe35
      6634a108
  29. Jul 13, 2013
    • Nick Kralevich's avatar
      remove "self:process ptrace" from domain, netd neverallow rules · 9a19885c
      Nick Kralevich authored
      Remove "self:process ptrace" from all SELinux enforced domains.
      In general, a process should never need to ptrace itself.
      We can add this back to more narrowly scoped domains as needed.
      
      Add a bunch of neverallow assertions to netd.te, to verify that netd
      never gets unexpected capabilities.
      
      Change-Id: Ie862dc95bec84068536bb64705667e36210c5f4e
      9a19885c
  30. Jul 11, 2013
    • Nick Kralevich's avatar
      domain.te: allow access to /sys/kernel/debug/tracing/trace_marker · 8758cc5f
      Nick Kralevich authored
      Bug: 9781325
      Change-Id: Ib6f6875f690420b59fceb0a32590a2b9ed8dda95
      8758cc5f
    • Nick Kralevich's avatar
      domain.te: Add backwards compatibility for unlabeled files · 0c9708b2
      Nick Kralevich authored
      For unlabeled files, revert to DAC rules. This is for backwards
      compatibility, as files created before SELinux was in place may
      not be properly labeled.
      
      Over time, the number of unlabeled files will decrease, and we can
      (hopefully) remove this rule in the future.
      
      To prevent inadvertantly introducing the "relabelto" permission, add
      a neverallow domain, and add apps which have a legitimate need to
      relabel to this domain.
      
      Bug: 9777552
      Change-Id: I71b0ff8abd4925432062007c45b5be85f6f70a88
      0c9708b2
  31. Jun 28, 2013
    • Nick Kralevich's avatar
      Enable SELinux protections for netd. · dbd28d91
      Nick Kralevich authored
      This change does several things:
      
      1) Restore domain.te to the version present at
      cd516a32 . This is the version
      currently being distributed in AOSP.
      
      2) Add "allow domain properties_device:file r_file_perms;" to
      domain.te, to allow all domains to read /dev/__properties__ .
      This change was missing from AOSP.
      
      3) Restore netd.te to the version present at
      80c9ba52 . This is the version
      currently being distributed in AOSP.
      
      4) Remove anything involving module loading from netd.te. CTS
      enforces that Android kernels can't have module loading enabled.
      
      5) Add several new capabilities, plus data file rules, to
      netd.te, since netd needs to write to files owned by wifi.
      
      6) Add a new unconfined domain called dnsmasq.te, and allow
      transitions from netd to that domain. Over time, we'll tighten up
      the dnsmasq.te domain.
      
      7) Add a new unconfined domain called hostapd.te, and allow
      transitions from netd to that domain. Over time, we'll tighten up
      the hostapd.te domain.
      
      The net effect of these changes is to re-enable SELinux protections
      for netd. The policy is FAR from perfect, and allows a lot of wiggle
      room, but we can improve it over time.
      
      Testing: as much as possible, I've exercised networking related
      functionality, including turning on and off wifi, entering airplane
      mode, and enabling tethering and portable wifi hotspots. It's quite
      possible I've missed something, and if we experience problems, I
      can roll back this change.
      
      Bug: 9618347
      Change-Id: I23ff3eebcef629bc7baabcf6962f25f116c4a3c0
      dbd28d91
  32. May 20, 2013
    • repo sync's avatar
      Make all domains unconfined. · 77d4731e
      repo sync authored
      This prevents denials from being generated by the base policy.
      Over time, these rules will be incrementally tightened to improve
      security.
      
      Change-Id: I4be1c987a5d69ac784a56d42fc2c9063c402de11
      77d4731e
  33. Apr 05, 2013
    • Stephen Smalley's avatar
      run-as policy fixes. · 74ba8c86
      Stephen Smalley authored
      - Remove dac_read_search as it is no longer required by run-as.
      - Introduce a separate type for /dev/tty so that we can allow use of own tty for
      for a run-as shell without allowing access to other /dev/tty[0-9]* nodes.
      - Allow sigchld notifications for death of run-as and its descendants by adbd.
      - Drop redundant rules for executing shell or system commands from untrusted_app;
      now covered by rules in app.te.
      
      Change-Id: Ic3bf7bee9eeabf9ad4a20f61fbb142a64bb37c6c
      74ba8c86
Loading