Skip to content
Snippets Groups Projects
  1. Apr 10, 2018
    • Jeff Vander Stoep's avatar
      Start the process of locking down proc/net · 08731895
      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
      08731895
    • Florian Mayer's avatar
      Expose filesystem read events in SELinux policy. · 7ad383f1
      Florian Mayer authored
      Without this, we only have visibility into writes.
      
      Looking at traces, we realised for many of the files we care about (.dex, .apk)
      most filesystem events are actually reads.
      
      See aosp/661782 for matching filesystem permission change.
      
      Bug: 73625480
      
      Change-Id: I6ec71d82fad8f4679c7b7d38e3cb90aff0b9e298
      7ad383f1
  2. Apr 09, 2018
    • Alan Stokes's avatar
      Revert "Add /sys/kernel/memory_state_time to sysfs_power." · 12e73685
      Alan Stokes authored
      This reverts commit db83323a.
      
      Reason for revert: breaks some builds due to duplicate genfs entries
      
      Change-Id: I47813bd84ff10074a32cf483501a9337f556e92a
      12e73685
    • Alan Stokes's avatar
      Add /sys/kernel/memory_state_time to sysfs_power. · db83323a
      Alan Stokes authored
      This allows system_server to access it for determining battery stats
      (see KernelMemoryBandwidthStats.java).
      
      batterystats-wo: type=1400 audit(0.0:429): avc: denied { read } for name="show_stat" dev="sysfs" ino=48071 scontext=u:r:system_server:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
      
      Bug: 72643420
      Bug: 73947096
      
      Test: Denial is no longer present.
      Change-Id: Ibe46aee48eb3f78fa5a9d1f36602c082c33036f7
      
      (cherry picked from commit a8b3634d)
      db83323a
  3. Apr 06, 2018
    • Alan Stokes's avatar
      Add /sys/kernel/memory_state_time to sysfs_power. · a8b3634d
      Alan Stokes authored
      This allows system_server to access it for determining battery stats
      (see KernelMemoryBandwidthStats.java).
      
      batterystats-wo: type=1400 audit(0.0:429): avc: denied { read } for name="show_stat" dev="sysfs" ino=48071 scontext=u:r:system_server:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
      
      Bug: 72643420
      Bug: 73947096
      
      Test: Denial is no longer present.
      Change-Id: Ibe46aee48eb3f78fa5a9d1f36602c082c33036f7
      a8b3634d
  4. Apr 03, 2018
  5. Mar 30, 2018
    • Florian Mayer's avatar
      SELinux changes for I/O tracing. · 9fcf22bb
      Florian Mayer authored
      See also go/perfetto-io-tracing-security.
      
      * Grant CAP_DAC_READ_SEARCH to traced_probes.
      * Allow traced_probes to list selected labels.
      * Change ext4 and f2fs events to be available on user builds.
      
      Bug: 74584014
      Change-Id: I891a0209be981d760a828a69e4831e238248ebad
      9fcf22bb
  6. Mar 29, 2018
    • Joel Galenson's avatar
      Label /proc/sys/kernel/sched_schedstats. · 4b625e4a
      Joel Galenson authored
      This allows init to write to it, which it does for atrace.
      
      Bug: 72643420
      Test: Boot two devices, observe no denials, test atrace.
      Change-Id: I6810e5dcdfaff176bd944317e66d4fe612ccebed
      (cherry picked from commit dce07413)
      4b625e4a
    • Florian Mayer's avatar
      SELinux changes for I/O tracing. · 8d819055
      Florian Mayer authored
      See also go/perfetto-io-tracing-security.
      
      * Grant CAP_DAC_READ_SEARCH to traced_probes.
      * Allow traced_probes to list selected labels.
      * Change ext4 and f2fs events to be available on user builds.
      
      Bug: 74584014
      Cherry-picked from aosp/631805
      Change-Id: I891a0209be981d760a828a69e4831e238248ebad
      Merged-In: I891a0209be981d760a828a69e4831e238248ebad
      8d819055
    • Joel Galenson's avatar
      Label /proc/sys/kernel/sched_schedstats. · dce07413
      Joel Galenson authored
      This allows init to write to it, which it does for atrace.
      
      Bug: 72643420
      Test: Boot two devices, observe no denials, test atrace.
      Change-Id: I6810e5dcdfaff176bd944317e66d4fe612ccebed
      dce07413
  7. Feb 13, 2018
    • Primiano Tucci's avatar
      Allow perfetto traced_probes to access tracefs on user · b4b31f9d
      Primiano Tucci authored
      Allows the traced_probes daemon to access the core ftrace
      functionalities on user builds. Specifically this involves:
      - Whitelisting the per_cpu/ subdirectory to access:
        1) trace_pipe_raw file to allow perfetto to read the raw
           ftrace buffer (rather than the text-based /trace endpoint)
        2) cpuX/stats and cpuX/buffer_size_kb that allow to
           tune the buffer size per-cpu pipe and to get basic
           statistics about the ftrace buffer (#events, overruns)
      - Whitelistiing the full event directories rather than the
        /enable files. This gives also access to the /format files
        for the events that are already enabled on user builds.
        /format files simply describe the memory layout
        of the binary logs. Example: https://ghostbin.com/paste/f8m4k
      
      This still does NOT allow enabling the events labeled as
      "_debug" (mostly events that return activity on inodes).
      We'll deal with that separately as soon as we get a POC
      of inode resolution and a sensible blacklist/whitelist model.
      
      Bug: 70942310
      Change-Id: Ic15cca0a9d7bc0e45aa48097a94eadef44c333f8
      b4b31f9d
  8. Feb 07, 2018
  9. Feb 05, 2018
    • Carmen Jackson's avatar
      Use a whitelisting strategy for tracefs. · 2c8ca45d
      Carmen Jackson authored
      This changes tracefs files to be default-enabled in debug mode, but
      default-disabled with specific files enabled in user mode.
      
      Bug: 64762598
      Test: Successfully took traces in user mode.
      
      Change-Id: I572ea22253e0c1e42065fbd1d2fd7845de06fceb
      2c8ca45d
  10. Jan 24, 2018
    • Marissa Wall's avatar
      sepolicy: restrict access to uid_cpupower files · dfe063c3
      Marissa Wall authored
      Do not let apps read /proc/uid_cpupower/time_in_state,
      /proc/uid_cpupower/concurrent_active_time,
      /proc/uid_cpupower/concurrent_policy_time.
      
      b/71718257
      
      Test: Check that they can't be read from the shell
          without root permissions and system_server was able
          to read them
      
      Change-Id: I812694adfbb4630f7b56aa7096dc2e6dfb148b15
      dfe063c3
    • Joel Galenson's avatar
      Fix init error trying to access file. · cf391269
      Joel Galenson authored
      Init tries to write /proc/sys/vm/min_free_order_shift but fails due to
      a SELinux denial.  This gives the file a new label and gives init the
      ability to write it.
      
      Test: Build and booted Sailfish (a couple of days ago).
      Change-Id: Ic93862b85c468afccff2019d84b927af9ed2a84d
      cf391269
  11. Jan 23, 2018
  12. Jan 20, 2018
  13. Jan 19, 2018
    • Daniel Rosenberg's avatar
      Label esdfs as sdcardfs · 9d0d6856
      Daniel Rosenberg authored
      Test: esdfs should be mountable and usable with selinux on
      Bug: 63876697
      Change-Id: I7a1d96d3f0d0a6dbc1c98f0c4a96264938011b5e
      9d0d6856
  14. Jan 11, 2018
    • Jeff Vander Stoep's avatar
      relabel files in /proc/net/xt_qtaguid/ · 43303c8b
      Jeff Vander Stoep authored
      /proc/net/xt_qtaguid is used by apps to track their network data
      use. Limit access to just zygote spawned processes - apps and
      system_server, omitting access to isolated_app which is not allowed
      to create network sockets.
      As Android moves to eBPF for app's network data stats, access to
      /proc/net/xt_qtaguid will be removed entirely. Segmenting access off
      is the first step.
      Bug: 68774956
      
      This change also helps further segment and whitelist access to
      files in /proc/net and is a step in the lockdown of /proc/net.
      Bug: 9496886
      
      Test: boot Taimen. Walk through setup-wizard. Make phone call and
          video call. Browse web. Watch youtube. Navigate in maps.
      Test: cts-tradefed run cts -m CtsAppSecurityHostTestCases -t \
          android.appsecurity.cts.AppSecurityTests
      Test: cts-tradefed run cts -m CtsNativeNetTestCases
      Test: cts-tradefed run cts -m CtsIncidentHostTestCases -t \
          com.android.server.cts.NetstatsIncidentTest
      Test: cts-tradefed run cts -m CtsOsTestCases -t \
          android.os.cts.StrictModeTest
      Test: cts-tradefed run cts -m CtsNetTestCases -t \
          android.net.cts.TrafficStatsTest
      Test: cts-tradefed run cts -m CtsUsageStatsTestCases -t \
          android.app.usage.cts.NetworkUsageStatsTest
      Test: vts-tradefed run vts -m VtsQtaguidTest
      Change-Id: Idddd318c56b84564142d37b11dcc225a2f2800ea
      43303c8b
  15. Jan 08, 2018
  16. Jan 02, 2018
    • Chenbo Feng's avatar
      sepolicy: Allow mount cgroupv2 and bpf fs · 254ad0da
      Chenbo Feng authored
      Some necessary sepolicy rule changes for init process to create directory,
      mount cgroupv2 module and mount bpf filesystem. Also allow netd to create
      and pin bpf object as files and read it back from file under the
      directory where bpf filesystem is mounted.
      
      Test: bpf maps show up under /sys/fs/bpf/
      Change-Id: I579d04f60d7e20bd800d970cd28cd39fda9d20a0
      254ad0da
  17. Dec 22, 2017
  18. Dec 16, 2017
    • Jeff Vander Stoep's avatar
      Audit app access to /proc/net/* · 84f96859
      Jeff Vander Stoep authored
      Many processes including third party apps are expected to
      access /proc/net/xt_qtaguid/stats. Give this file a new label
      to avoid spamming the logs and temporarily grant read access to
      all processes.
      
      Read-only permission is adequate for all processes based on unix
      permissions.
      sailfish:/ # ls -laZ /proc/net/xt_qtaguid/stats
      -r--r--r--  1 root net_bw_stats u:object_r:proc_net_xt_qtaguid_stats:s0 stats
      
      Bug: 9496886
      Bug: 68016944
      Bug: 70722355
      Test: Build/flash Sailfish. Browse in Chrome and watch videos in youtube.
          No "denied" or "granted" selinux messages observed in the logs.
      
      Change-Id: I29f1ee806c8149988b9b93a950790d14754927ef
      84f96859
  19. 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
  20. Dec 09, 2017
    • Tri Vo's avatar
      Label /sys/class/net as sysfs_net. · c135f0ac
      Tri Vo authored
      We already expect contents of /sys/class/net to be labeled as sysfs_net.
      Also label the directory for consistensy since we usually label
      /sys/class/foo directories as sysfs_foo.
      
      Bug: 65643247
      Test: netd_integration_test
      Test: can browse internet without denials to sysfs_net
      Change-Id: I9d28ab4baf71df99ae966276532f14684d1abca6
      c135f0ac
  21. Dec 06, 2017
    • Andreas Gampe's avatar
      Sepolicy: Label kernel notes · 9213fe02
      Andreas Gampe authored
      Label /sys/kernel/notes.
      
      Bug: 70275668
      Test: m
      Change-Id: Ieb666425d2db13f85225fb902fe06b0bf2335bef
      9213fe02
    • Tri Vo's avatar
      init: remove open, read, write access to 'sysfs' type. · 0e3235f4
      Tri Vo authored
      Add write access to:
      sysfs_android_usb
      sysfs_leds
      sysfs_power
      sysfs_zram
      
      Add setattr access to:
      sysfs_android_usb
      sysfs_devices_system_cpu
      sysfs_lowmemorykiller
      sysfs_power
      sysfs_leds
      sysfs_ipv4
      
      Bug: 70040773
      Bug: 65643247
      Change-Id: I68e2e796f5599c9d281897759c8d8eef9363559a
      Test: walleye boots with no denials from init to sysfs.
      0e3235f4
  22. Dec 01, 2017
  23. Nov 29, 2017
  24. Nov 28, 2017
    • Tri Vo's avatar
      Label /proc/sys/kernel/pid_max as proc_pid_max. · 4081fd39
      Tri Vo authored
      And give shell domain read access to /proc/sys/kernel/pic_max.
      
      Bug: 69569397
      Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
      --gtest_filter=pthread.pthread_mutex_owner_tid_limit
      Change-Id: Ib56c18ed553ad2c2113e6913788a4c00965483cc
      4081fd39
  25. Nov 16, 2017
    • Tri Vo's avatar
      system_server: access to /proc/sys/fs/pipe-max-size · e7f4934d
      Tri Vo authored
      Label /proc/sys/fs/pipe-max-size with new type proc_pipe_conf and give
      system_server access to it.
      
      Addresses this denial:
      avc: denied { read } for name="pipe-max-size" dev="proc" ino=93817
      scontext=u:r:system_server:s0 tcontext=u:object_r:proc:s0 tclass=file
      permissive=0
      
      Bug: 69175449
      Bug: 69324398
      Test: sailfish boots
      Test: adb bugreport
      Test: craft an unresponsive app, trigger ANR, make sure traces are dumped
      into /data/anr
      Above denial from system_server not observed, no denials to proc_pipe_conf
      observed.
      Change-Id: I7c71f05820a4945ba982e29f76e9d9f4458b2b59
      e7f4934d
  26. Nov 08, 2017
    • Tri Vo's avatar
      init: label /proc dependencies and remove access to proc · 84e181bc
      Tri Vo authored
      New types and files labeled with them:
      1. proc_abi:
        /proc/sys/abi/swp
      
      2. proc_dirty:
        /proc/sys/vm/dirty_background_ratio
        /proc/sys/vm/dirty_expire_centisecs
      
      3. proc_diskstats:
        /proc/diskstats
      
      4. proc_extra_free_kbytes:
        /proc/sys/vm/extra_free_kbytes
      
      5. proc_hostname:
        /proc/sys/kernel/domainname
        /proc/sys/kernel/hostname
      
      6. proc_hung_task:
        /proc/sys/kernel/hung_task_timeout_secs
      
      7. proc_max_map_count:
        /proc/sys/vm/max_map_count
      
      8. proc_panic:
        /proc/sys/kernel/panic_on_oops
      
      9. proc_sched:
        /proc/sys/kernel/sched_child_runs_first
        /proc/sys/kernel/sched_latency_ns
        /proc/sys/kernel/sched_rt_period_us
        /proc/sys/kernel/sched_rt_runtime_us
        /proc/sys/kernel/sched_tunable_scaling
        /proc/sys/kernel/sched_wakeup_granularity_ns
      
      10. proc_uptime:
        /proc/uptime
      
      Files labeled with already existing types:
      1. proc_perf:
        /proc/sys/kernel/perf_event_paranoid
      
      2. proc_sysrq:
        /proc/sys/kernel/sysrq
      
      3. usermodehelper:
        /proc/sys/kernel/core_pipe_limit
      
      Changes to init domain:
      1. Removed access to files with 'proc' label.
      2. Added access to newly introduced types + proc_kmsg.
      
      Bug: 68949041
      Test: walleye boots without denials from u:r:init:s0.
      Test: system/core/init/grab-bootchart.sh does not trigger denials from
      u:r:init:s0
      Change-Id: If1715c3821e277679c320956df33dd273e750ea2
      84e181bc
    • Luis Hector Chavez's avatar
      Allow callers of uevent_kernel_*() access to /proc/sys/kernel/overflowuid · 640e595a
      Luis Hector Chavez authored
      Bug: 62378620
      Test: Android in Chrome OS can call uevent_kernel_recv() and not fail
            with EIO.
      Test: bullhead networking still works
      
      Change-Id: I4dd5d2148ee1704c4fa23d7fd82d1ade19b58cbd
      640e595a
  27. Oct 24, 2017
    • Tom Cherry's avatar
      Add label for /proc/sys/vm/page-cluster · 8bdb1dab
      Tom Cherry authored
      Test: boot sailfish with no audit when writing to page-cluster
      Change-Id: I2bfebdf9342594d66d95daaec92d71195c93ffc8
      8bdb1dab
    • Tri Vo's avatar
      /proc, /sys access from uncrypt, update_engine, postinstall_dexopt · 04fb82f2
      Tri Vo authored
      New types:
      1. proc_random
      2. sysfs_dt_firmware_android
      
      Labeled:
      1. /proc/sys/kernel/random as proc_random.
      2. /sys/firmware/devicetree/base/firmware/android/{compatible, fstab,
      vbmeta} as sysfs_dt_firmware_android.
      
      Changed access:
      1. uncrypt, update_engine, postinstall_dexopt have access to generic proc
      and sysfs labels removed.
      2. appropriate permissions were added to uncrypt, update_engine,
      update_engine_common, postinstall_dexopt.
      
      Bug: 67416435
      Bug: 67416336
      Test: fake ota go/manual-ab-ota runs without denials
      Test: adb sideload runs without denials to new types
      Change-Id: Id31310ceb151a18652fcbb58037a0b90c1f6505a
      04fb82f2
  28. Oct 20, 2017
    • Tri Vo's avatar
      Restrict netd fwk policy. · 8dabc2ce
      Tri Vo authored
      Remove netd access to sysfs_type attribute.
      
      These were moved from vendor to fwk policy:
      1. sysfs_net type declaration
      2. labeling of /sys/devices/virtual/net with sysfs_net
      3. netd access to sysfs_net
      
      Bug: 65643247
      Test: can browse internet without netd denials
      Test: netd_unit_test, netd_integration_test without netd denials
      Merged-In: Ic1b95a098f438c4c6bc969bee801bf7dd1a13f6e
      Change-Id: Ic1b95a098f438c4c6bc969bee801bf7dd1a13f6e
      (cherry picked from commit e62a56b7)
      8dabc2ce
    • Tri Vo's avatar
      Restrict netd fwk policy. · c1031b55
      Tri Vo authored
      Remove netd access to sysfs_type attribute.
      
      These were moved from vendor to fwk policy:
      1. sysfs_net type declaration
      2. labeling of /sys/devices/virtual/net with sysfs_net
      3. netd access to sysfs_net
      
      Bug: 65643247
      Test: can browse internet without netd denials
      Test: netd_unit_test, netd_integration_test without netd denials
      Merged-In: Ic1b95a098f438c4c6bc969bee801bf7dd1a13f6e
      Change-Id: Ic1b95a098f438c4c6bc969bee801bf7dd1a13f6e
      (cherry picked from commit e62a56b7)
      c1031b55
Loading