Commit graph

798 commits

Author SHA1 Message Date
Treehugger Robot
edaed3ed7a Merge "Allocate a GID range for external cache files." 2017-04-18 22:34:16 +00:00
Steven Moreland
d73be1b96b libcutils: compile with BOARD_VNDK_VERSION current
- moved __android_log_is_debuggable to a new public header
    (log_properties.h)
- vendor version of sched_policy uses ALOG* instead SLOG*

Test: (sanity) liblog-unit-tests
Test: (sanity) libcutils_test (noting b/b/32972117, two tests continue
  to fail)
Test: system/core as a whole makes with BOARD_VNDK_VERSION := current
  now with no problems.
Test: boots/works on internal marlin
Bug: 33241851

(cherry picked from commit 1f83aa424f)

Merged-In: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
Change-Id: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
2017-04-17 14:44:17 -07:00
Jeff Sharkey
fa16473921 Allocate a GID range for external cache files.
We can't reuse the GID range for internal cache files, otherwise
we don't have a way to tease apart the difference when deciding if
it's safe to move apps.

Test: builds, boots
Bug: 37193650
Change-Id: I22c4e575cd557636e74c5c73035adb1d4dcbb7f7
2017-04-17 14:50:27 -06:00
Josh Gao
0301b3217b Merge changes from topics 'adb_thread', 'adb_loopback'
* changes:
  adb: statically link libbase into the tests.
  adb: kill adb_thread_{create, join, detach, exit}.
  adb: don't try to resolve 'localhost'
2017-04-14 20:04:04 +00:00
Josh Gao
46de1d7f03 adb: don't try to resolve 'localhost'
Misconfigured systems can have localhost pointing to an address that
isn't 127.0.0.1 or ::1.

adb is the only caller of the libcutils socket_loopback functions, so
move them into adb and switch the implementations over to using
INADDR_LOOPBACK and in6addr_loopback, instead of resolving 'localhost'
when connecting.

Bug: http://b/37282612
Test: `killall adb; adb shell`
Test: `killall adb; ip addr del 127.0.0.1/8 dev lo; adb shell`
Change-Id: I01c1885f1d9757ad0f7b353dd04b4d1f057741c8
2017-04-12 16:07:49 -07:00
Ganesh Mahendran
6748f24d70 libcutils: fix system-background tasks shown in top command
tasks in system-background cgroup will be shown as below:
 580   580 system   12  -8   1% S 190656K  19408K unk surfaceflinger  /system/bin/surfaceflinger

This patch fix this issue.

Change-Id: Ib39ff892010498548d7fbfb4021df62498acd033
Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
2017-04-12 16:25:25 +08:00
Mark Salyzyn
6e9cb8fd79 libcutils: fs_config: target_out_path assumed /system breaking partitions
Strip off trailing / then /system and then add back the appropriate
config directory.  This fixes an issue with reading vendor, oem or odm
partitions.

Test: manual build successfully interprets all etc/fs_config_* files.
Test: manual incremental build successfully interprets all etc/fs_config_* files.
Bug: 36071012
Change-Id: Iba363f0731bb8d15e595bb45c56db97722edabc2
2017-04-07 10:29:51 -07:00
Thierry Strudel
29e0c8f1a9 Revert "libcutils: fs_config: target_out_path assumed /system"
This reverts commit 7130fb345d.

Bug: 36816191
Change-Id: I7d604d510865b1fa15781ffb4ad8b3e77ac44395
2017-04-07 00:34:03 +00:00
Mark Salyzyn
7130fb345d libcutils: fs_config: target_out_path assumed /system
Strip off /system/ and add appropriate config directory.

Test: manual build successfully interprets all etc/fs_config_* files.
Bug: 36071012
Change-Id: I2563248e91cea10fef3cc2f9e954e4782fdfce4f
2017-04-05 22:32:22 +00:00
Treehugger Robot
c1c0de3945 Merge "Add test config to libcutils_test" 2017-04-05 06:39:42 +00:00
Mark Salyzyn
a9403f0db8 libcutils: create private/fs_config.h
private/fs_config.h is required in order to build an independent
test that requires internal binary knowledge of the
etc/fs_config_(files|dirs) files.

Test: compile
Bug: 36071012
Change-Id: I268bcfdbb6d45b7bf6040cbf307a4e34812f5fef
2017-04-04 19:14:32 +00:00
Jeff Sharkey
d185445eee Revert "Allocate GID to use reserved disk space."
This reverts commit 82f8bb785e.

Sadly, we'd have to extend CAP_SYS_RESOURCE to a bunch of execution
domains to make this work, which isn't feasible.

Bug: 36450358
Change-Id: Iffe88e45d538c044382eb0d0ac24ff11a10d73c3
2017-04-03 04:00:36 +00:00
Dan Shi
2c67dfbc09 Add test config to libcutils_test
This change allows TradeFederation to run the test directly.
Refer to b/35882476 for design and discussion of this change.

Bug: 35882476
Test: local test
tradefed.sh run template/local --template:map test=libcutils_test

Change-Id: Ie083d1641e4ea226cbf7b82c6fd2c115e15b6bf6
2017-03-31 17:12:18 -07:00
Jeff Sharkey
82f8bb785e Allocate GID to use reserved disk space.
Filesystems like ext4 allow the setting of the "resgid" parameter
to designate a GID that is allowed to use the "reserved" disk space
(in addition to UID 0).  We'll be granting this GID to critical
system processes, so that the system is usable enough for the user
to free up disk space used by apps.

Test: builds
Bug: 36450358
Change-Id: I224bd1e597130edb411a1528872faff1ada02a89
2017-03-31 16:39:45 -06:00
Dan Shi
d8f533aab2 Add test config to libcutils_test_static
Design doc:
Generalized Suites & the Unification of APCT & CTS Workflows Design/Roadmap
https://docs.google.com/document/d/1eabK3srlBLouMiBMrNP3xJPiRRdcoCquNxC8gBWPvx8/edit#heading=h.78vup5eivwzo

Details about test configs changes are tracked in doc
https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit#

Bug: 35882476
Test: local test
Change-Id: I9faa1c929fff43635aff06b4228501e1227c4d06
2017-03-29 23:13:08 -07:00
Wei Wang
a8d59faa75 libcutils: remove sched_set/getscheduler
Bug: 36667354
Test: angler taking video
Change-Id: Ie7fbcccbd02314468c03317319574ee7e433561d
2017-03-28 13:01:20 -07:00
Jeremy Compostella
3d642d48e2 libcutils: handle root directory empty path
Usually, the canned paths lack the leading '/' which means that the
root directory is an empty path.  This patch makes
load_canned_fs_config() handle this empty path as the root directory.
It also make it flexible enough to handle an optional leading '/'.

Original-Author: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Gaelle Nassiet <gaellex.nassiet@intel.com>
Change-Id: Ice759ef37d1df23a54df1158ec0d3ad7f577a069
2017-03-28 14:57:22 +00:00
Wei Wang
40267986da libcutils: remove schedgroup
After removing bg_non_interactive cgroup, there is only a ROOT cgroup.
This CL removes the no-op trying to set cgroup.
It also removes the attempt to open non-exist bg_non_interactive cgroup.

Bug: 36649832
Test: marlin boosts and cgroup ROOT task looks normal
Change-Id: Ibccd6db1499306174c940aec9219b20c1b86173d
2017-03-27 11:57:29 -07:00
Lorenzo Colitti
438720ac2c Merge "Make the xtables lock readable only by AID_RADIO and root." 2017-03-24 06:25:38 +00:00
Mark Salyzyn
2b616cea9e libcutils: fs_config() add check /odm/etc/fs_config_*
Add reading of vendor file-system config files
/odm/etc/fs_config_dirs and /odm/etc/fs_config_files.

Order of interpretation (for dirs and files respectively):
- /system/etc/fs_config_dirs or /system/etc/fs_config_files
- /vendor/etc/fs_config_dirs or /vendor/etc/fs_config_files
- /oem/etc/fs_config_dirs or /oem/etc/fs_config_files
- /odm/etc/fs_config_dirs or /odm/etc/fs_config_files
- internal android_dirs[] or android_files[] structures.

No restrictions are placed on the odm file-system config files,
although the developer is advised to restrict the scope to the /odm
file-system since the intent is to provide support only for
customized portions of odm.img.

Test: full build and install smoke test and inspection
Bug: 36071012
Change-Id: Ic3afb5bb4ea20b15bd5df728be9f16045bf5b039
2017-03-22 15:28:40 -07:00
Treehugger Robot
437dc91fa3 Merge "remove emergency shutdown and improve init's reboot logic" 2017-03-22 20:13:43 +00:00
Keun-young Park
8d01f63f50 remove emergency shutdown and improve init's reboot logic
- Emergency shutdown just marks the fs as clean while leaving fs
  in the middle of any state. Do not use it anymore.

- Changed android_reboot to set sys.powerctl property so that
  all shutdown can be done by init.

- Normal reboot sequence changed to
    1. Terminate processes (give time to clean up). And wait for
      completion based on ro.build.shutdown_timeout.
        Default value (when not set) is changed to 3 secs. If it is 0, do not
        terminate processes.
    2. Kill all remaining services except critical services for shutdown.
    3. Shutdown vold using "vdc volume shutdown"
    4. umount all emulated partitions. If it fails, just detach.
       Wait in step 5 can handle it.
    5. Try umounting R/W block devices for up to max timeout.
      If it fails, try DETACH.
      If umount fails to complete before reboot, it can be detected when
      system reboots.
    6. Reboot

- Log shutdown time and umount stat to log so that it can be collected after reboot

- To umount emulated partitions, all pending writes inside kernel should
  be completed.
- To umount /data partition, all emulated partitions on top of /data should
  be umounted and all pending writes should be completed.
- umount retry will only wait up to timeout. If there are too many pending
  writes, reboot will discard them and e2fsck after reboot will fix any file system
  issues.

bug: 36004738
bug: 32246772

Test: many reboots combining reboot from UI and adb reboot. Check last_kmsg and
      fs_stat after reboot.

Change-Id: I6e74d6c68a21e76e08cc0438573d1586fd9aaee2
2017-03-22 11:23:31 -07:00
Lorenzo Colitti
5e801e7bd5 Make the xtables lock readable only by AID_RADIO and root.
Anyone who can read this file can call flock(..., LOCK_EX) on it,
thereby blocking any future iptables commands from running.
Restrict it to user AID_RADIO, which includes device-specific
network management daemons, and group root.

Bug: 36108349
Test: see https://android-review.googlesource.com/#/c/348939/
Change-Id: I4dae4b5a835fabdc1a61a330e0446b39651f8156
2017-03-22 17:03:19 +09:00
Vijay Venkatraman
d4e2386057 Moved include/android_filesystem_*.h and canned_fs_config.h to libcutils
Bug: 33241851
Test: No changes needed for modules not using VNDK.
For VNDK, enable BOARD_VNDK_VERSION in BoardConfig.mk
and add libcutils to modules that need these headers.

Change-Id: I6102778aab35ed26a5ddde11230502dcd4edc852
2017-03-21 17:34:58 -07:00
Treehugger Robot
e941c5fa41 Merge changes from topic 'remove_bg_cgroup'
* changes:
  libcutils: only change cgroup when fd is initialized
  init.rc: remove bg_non_interactive cgroup
2017-03-21 22:09:51 +00:00
Mark Salyzyn
62c701e174 libcutils: fs_config() add check /oem/etc/fs_config_*
Add reading of vendor file-system config files
/oem/etc/fs_config_dirs and /oem/etc/fs_config_files.

Order of interpretation (for dirs and files respectively):
- /system/etc/fs_config_dirs or /system/etc/fs_config_files
- /vendor/etc/fs_config_dirs or /vendor/etc/fs_config_files
- /oem/etc/fs_config_dirs or /oem/etc/fs_config_files
- internal android_dirs[] or android_files[] structures.

No restrictions are placed on the oem file-system config files,
although the developer is advised to restrict the scope to the /oem
file-system since the intent is to provide support only for
customized portions of oem.img.

Test: full build and install smoke test and inspection
Bug: 36071012
Change-Id: I56f3fed5efa44d622a9a110937dbc949083d44ae
2017-03-21 08:15:58 -07:00
Mark Salyzyn
9ceadcb0c4 libcutils: fs_config() add check /vendor/etc/fs_config_*
Add reading of vendor file-system config files
/vendor/etc/fs_config_dirs and /vendor/etc/fs_config_files.

Order of interpretation (for dirs and files respectively):
- /system/etc/fs_config_dirs or /system/etc/fs_config_files
- /vendor/etc/fs_config_dirs or /vendor/etc/fs_config_files
- internal android_dirs[] or android_files[] structures.

No restrictions are placed on the vendor file-system config files,
although the developer is advised to restrict the scope to the /vendor
file-system since the intent is to provide support only for
customized portions of vendor.img.

Test: full build and install smoke test and inspection
Bug: 36071012
Change-Id: I4077bd6afcda2ee16189b2eb3c322af15205bbb9
2017-03-21 08:14:42 -07:00
Mark Salyzyn
a45eae93f6 libcutils: fs_config: sort files
Sort android_files[] first by requirements, grouping, specificity and
finally by alphanumeric order.

Test: full build and install smoke test and inspection
Bug: 36071012
Change-Id: I92c4090eac0067e0327ac7c8dde229747893d585
2017-03-21 08:14:42 -07:00
Mark Salyzyn
c4f9f4c216 libcutils: fs_config: sort dirs
Sort android_dirs[] first by requirements, grouping, specificity and
finally by alphanumeric order.

Test: full build and install smoke test and inspection
Bug: 36071012
Change-Id: Iff579600b05d7b2a0b9fc7d9e9d897e0bb69aebd
2017-03-21 08:14:42 -07:00
Wei Wang
97957fc420 libcutils: only change cgroup when fd is initialized
This is to avoid failues on setting non-exist cgroup

Bug: 34193533
Test: on marlin
Change-Id: I619dcba332fda9ec421df811745cf10311beddd3
2017-03-20 22:13:22 -07:00
Mark Salyzyn
166e24c91b libcutils: fs_config.c code compliance
Comply with clang-format. Adjust some comments.

Test: full build and install smoke test and inspection
Bug: 36071012
Change-Id: I459a08b4dc4333ab3d75207621a27587849386a5
2017-03-20 15:32:11 -07:00
Todd Poynor
e63f366ee3 android_reboot: move reboot reason file to data/misc/reboot/
Move last reboot reason file to new directory data/misc/reboot/ to
require only SELinux permissions specific to this new file.

Bug: 30994946
Test: manual: reboot command, setprop sys.powerctl
Change-Id: I1e067235aa4b06391cff8ab0741a9d317ba5b7da
2017-03-17 17:27:36 -07:00
Todd Poynor
eac33da63b libcutils: android_reboot: save reboot reason in file
Save a string identifying the reason for last Android reboot or power
off in file /data/misc/recovery/last_reboot_reason .  This file may
be used for informing users of reboot or shutdown reasons at next
boot, and for other diagnostic purposes.

Bug: 30994946
Test: Manual: reboot, setprop sys.powerctl
Change-Id: I01e44473fdd21b33e9e4dced77aba9a66b6d3755
2017-03-17 17:26:57 -07:00
Alex Deymo
4822b01b12 Update qtaguid tag/untag documentation.
The qtaguid_tagSocket() function tags a network socket by passing a
reference to the given socket to the qtaguid kernel module. The module
will keep the socket alive even if the process calls close() on said
socket. In this scenario, the socket object would not be destroyed
even if all the file descriptor.

While this is at least a memory leak, it plays bad with epoll(7)
if you also didn't remove the socket from the epoll fd before closing
since epoll will not notice that the socket was closed and there is no
way to remove the socket from epoll after it was closed.

This patch updates the documentation to explicitly mention that the
socket must be untag before closing or bad things happen.

Bug: 36264049
Test: None.
Change-Id: I564a9b6d11d22b43a6c12312524386c0338b42ed
2017-03-17 17:48:52 +00:00
Dan Willemsen
e0cd1e043d Enable more modules on linux_bionic builds
Bug: 31559095
Test: Enable host bionic, run soong
Change-Id: Ib4ebd909322cf464b6a40040e4b60ece7d905b6f
2017-03-15 15:44:00 -07:00
Todd Poynor
37bba3b88a libcutils: android_reboot: add thermal shutdown command
Add ANDROID_RB_THERMOFF command to android_reboot(), denoting a power
off due to thermal limits exceeded.  When this command is used, Android
may provide notification to the user about the potentially unexpected
power off at next boot.

Bug: 30994946
Test: Manual: setprop sys.powerctl thermal-shutdown
Change-Id: If2cde1b6a3c281a5750b50295412a4801ed5b2f2
2017-03-14 17:58:25 -07:00
Treehugger Robot
1e48879b6c Merge "Bluetooth hal: moved to vendor partition." 2017-02-28 04:00:58 +00:00
Steven Moreland
18676b2ca8 Bluetooth hal: moved to vendor partition.
Bug: 35328775
Test: works in both binderized and passthrough modes
Merged-In: I61f1ff6b777089d7aad5184c0aee4f653897b32e
Change-Id: I61f1ff6b777089d7aad5184c0aee4f653897b32e
2017-02-28 01:34:59 +00:00
Treehugger Robot
dfbae6ddbb Merge changes Iede18a00,Ib0fa24fb,Ic4c8a137
* changes:
  libcutils: build tests with -Wall -Wextra -Werror
  libcutils: fix socket type in SocketsTest.TestGetLocalPort
  libcutils: fix Wsign-compare warnings in multiuser_test
2017-02-28 00:11:07 +00:00
Alex Klyubin
3380927e71 Make secilc accessible by root only
There's no reason for SELinux policy compiler to be accessible by
anybode other than root.

Test: Device boots -- secilc isn't used yet anyway
Bug: 31363362
Change-Id: I26cf34f1412b8dd471f79271c491b473617a6df6
2017-02-27 13:27:58 -08:00
Greg Hackmann
a930af8921 libcutils: build tests with -Wall -Wextra -Werror
Test: mmm system/core/libcutils/tests

Change-Id: Iede18a008df5834b8ecedd6019c4444150748f68
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2017-02-22 10:58:38 -08:00
Greg Hackmann
7c60ec3029 libcutils: fix socket type in SocketsTest.TestGetLocalPort
With -Wall enabled locally, clang points out that the second parameter
to socket_inaddr_any_server() was accidentally hard-coded:

system/core/libcutils/tests/sockets_test.cpp:103:18: warning: unused variable 'type' [-Wunused-variable]
        for (int type : {SOCK_DGRAM, SOCK_STREAM}) {
                 ^

Bug: 26936282
Test: mmm system/core/libcutils/tests
Test: adb shell /data/nativetest/libcutils_test/libcutils_test32 \
	--gtest_filter=SocketsTest.TestGetLocalPort (on hikey)
Test: adb shell /data/nativetest64/libcutils_test/libcutils_test64 \
        --gtest_filter=SocketsTest.TestGetLocalPort (on hikey)

Change-Id: Ib0fa24fb02a5ee14db0afd6591a62089e43bbec0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2017-02-22 10:58:38 -08:00
Greg Hackmann
6d90fdc5e5 libcutils: fix Wsign-compare warnings in multiuser_test
gid_t and uid_t are unsigned ints, so we need to compare against unsigned
constants.

Bug: 26936282
Test: mmm system/core/libcutils/tests
Test: adb shell /data/nativetest/libcutils_test/libcutils_test32 \
	--gtest_filter=MultiuserTest.* (on hikey)
Test: adb shell /data/nativetest64/libcutils_test/libcutils_test64 \
	--gtest_filter=MultiuserTest.* (on hikey)

Change-Id: Ic4c8a137e3f37cb5e95ba925814f201cfd5a06b0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2017-02-22 10:58:34 -08:00
Isaac Chen
795267d4c7 Removed cpusets/schedboost build time dependency.
These two Soong product_variables were usually controlled by
ENABLE_CPUSETS and ENABLE_SCHEDBOOST in BoardConfig.mk. This change
turns the build time variables into runtime decision by checking if
a special file, "tasks", can be found under the mount points,
/dev/cpuset and /dev/stune, for cpusets and schedboost, respectively.

That special file only exists when the corresponding Linux kernel
configurations, CONFIG_CPUSETS and CONFIG_SCHEDTUNE, are set.

Bug: 34726944

Test: Tested on Sailfish with following configurations
          neither cpuset nor schedtune enabled in the kernel
          cpuset enabled, but schedtune disabled in the kernel
          both cpuset and schedtune enabled in the kernel

Change-Id: I6695b8b32b2fecb4fd995018418bbe2edc5d590f
2017-02-20 20:53:24 +08:00
Treehugger Robot
01003d40fc Merge "Implement android::base::WaitForProperty." 2017-02-14 03:48:26 +00:00
Steven Moreland
b7ca92349e fs_config: wifi is now on vendor partition
Bug: 34135607
Test: pass
Change-Id: I0c9dd9642e780a0303e6aaa6d80e443c59cc0c28
2017-02-13 17:21:17 -08:00
Elliott Hughes
b30769a87a Implement android::base::WaitForProperty.
Also adapt libcutils to the bionic change that was necessary for this.

Bug: http://b/35201172
Test: ran tests
Change-Id: I72a98b70b03d23e958b46778b505fbd5c86c32ae
2017-02-13 11:29:02 -08:00
George Burgess IV
67959bceb2
cutils: Add clang FORTIFY support
Bug: 32073964
Test: Builds on angler, bullhead, marlin, sailfish. Bionic CTS tests
pass on Angler and Bullhead.

Change-Id: I3d7f8ff73f92b1deb1e07f08282098e71e2d03a9
Signed-off-by: Alex Naidis <alex.naidis@linux.com>
2017-02-09 20:18:19 +01:00
Josh Gao
ac91b0c452 Revert "Give crash_dump CAP_SYS_PTRACE."
This reverts commit 36397cb168.

Bug: http://b/34853272
Test: debuggerd -b `pidof system_server`
Test: debuggerd -b `pidof zygote`
Change-Id: Ibccbccd956779f268d498a52aa737c1959538831
2017-02-01 17:55:22 -08:00
Evgenii Stepanov
54c7886c40 Disable integer sanitization on host.
Test: NFC until https://android-review.googlesource.com/#/c/329510
Change-Id: I4d1bb66821b2984bbee12438cfd72b9b63d56605
2017-01-31 16:33:53 -08:00