Commit graph

75210 commits

Author SHA1 Message Date
Bart Van Assche
59af680023 Add support for optional cgroup attributes
Cgroup attributes like io.weight or io.bfq.weight only exist if the
corresponding I/O scheduler has been loaded. Hence add support for
ignoring failures to write to a cgroup attribute that does not exist.

Bug: 213617178
Test: This patch has been tested in combination with patch "Migrate the blkio controller to the cgroup v2 hierarchy".
Change-Id: I5debafabc4dd430a1b98ea343bf3740c764edcc3
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-16 19:55:46 +00:00
Treehugger Robot
4e0a7f22fa Merge changes Ib5012456,Idbfb49c2,Ieb953c18
* changes:
  Use uid_t for user IDs and gid_t for group IDs
  Fix cgroup directory permissions
  Simplify cgroups.json
2022-03-16 19:53:41 +00:00
David Anderson
14f9c15e05 init: Add more diagnostics for signalfd hangs.
This adds two new diagnostics. First, signalfd reads are now non-blocking. If the read takes more than 10 seconds, we log an error.

Second, init now wakes up from epoll() every 10 seconds. If it waits on an "exec" command for more than 10 seconds, it logs an error.

This change will be reverted as soon as we get feedback.

Bug: 223076262
Test: device boots
Change-Id: I7ee98d159599217a641b3de2564a92c2435f57ef
2022-03-16 05:06:17 +00:00
Andrei Homescu
aa4ebf2ce1 Fix Errors.h on systems that define NO_ERROR
Some systems (originally only Windows) define their own
NO_ERROR macro that overlaps with the enumerator from Errors.h.
The enumerator is only defined if the macro was not.

Bug: 224644083
Test: m
Change-Id: Iee0932b5259b3bfcf6494656b27e6e7488319f5c
2022-03-16 02:15:04 +00:00
Andrei Homescu
5c15de21da Disable call stacks on every OS except Linux/Android
To keep libutils (and consequently libbinder) as compact
and portable as possible, this disables call stacks on all
operating systems except Linux and Android.

Bug: 224644083
Test: m
Change-Id: I0d77c49022e852c2b8607f555174c4f9d54ed3df
2022-03-16 01:35:19 +00:00
Bart Van Assche
32a9b1c320 Use uid_t for user IDs and gid_t for group IDs
This patch makes the intent of the code more clear without changing any
functionality since uid_t and gid_t are both aliases for uint32_t on
Android systems. See also
https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/types.h

Bug: 213617178
Test: Compile-tested only.
Change-Id: Ib5012456a7357e79368f00e71e9a280fd6f96063
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-15 23:02:20 +00:00
Bart Van Assche
990194fe2f Fix cgroup directory permissions
Cgroup attributes are set from three different contexts:
(1) From the process that creates the cgroup directories. These
    processes are /system/bin/init, zygote and zygote64.
(2) From the created process. Some but not all created processes have
    user ID and/or group ID 'system'.
(3) The system_server process modifies certain cgroup attributes from
    other processes.

Allow all processes from the system group, including system_server, to
modify cgroup attributes from other processes. As one can see in
init.rc, that file includes commands for granting the system group
write permission for blkcg attributes. See also
https://cs.android.com/android/platform/superproject/+/master:system/core/rootdir/init.rc

Bug: 213617178
Test: Verified in the Cuttlefish emulator that this patch makes the
Test: io.bfq.weight write errors disappear from logcat.
Change-Id: Idbfb49c25afec12b21daea7a17db5322bc981ff0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-15 23:02:20 +00:00
Bart Van Assche
f508ede763 Simplify cgroups.json
cgroups.json causes the following changes to be applied twice to
/sys/fs/cgroup: change user ID to system, change group ID to system and
change mode to 0755. Apply these settings once instead of twice.

Bug: 213617178
Test: Ran ls -ld /sys/fs/cgroup in Cuttlefish.
Change-Id: Ieb953c186c027b989599cbbaa70a9c9324678cdf
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-15 23:02:19 +00:00
Christopher Ferris
95c777072f Merge "Update for accurate unreadable elf files." 2022-03-15 22:20:08 +00:00
Treehugger Robot
00e57e0841 Merge "trusty: Update TIPC UAPI header" 2022-03-15 18:32:38 +00:00
Akilesh Kailash
d3f267200e Merge "Revert "init: Add diagnostics for snapuserd hangs"" 2022-03-15 17:49:35 +00:00
Christopher Ferris
c95047dd20 Update for accurate unreadable elf files.
The functionality moved from the Unwinder object to the MapInfo
object and means that the individual unreadable files can be
displayed now.

Included adding the unreadable elfs per thread in the protobuf.

Updated the unwinder test.

Test: All unit tests pass.
Change-Id: I7140bde16938736da005f926e10bbdb3dbc0f6f5
2022-03-15 09:50:48 -07:00
Jaegeuk Kim
120f6b260c Init: add dev.mnt.blk.bootdevice to access device sysfs
This patch adds a new property, 'dev.mnt.root.<mount_point>', which provides,
for example of /data,

1. dm-N
  dev.mnt.dev.data = dm-N
  dev.mnt.blk.data = sdaN or mmcblk0pN
  dev.mnt.rootdisk.data = sda or mmcblk0

2. sdaN or mmcblk0pN
  dev.mnt.dev.data = sdaN or mmcblk0pN
  dev.mnt.blk.data = sdaN or mmcblk0pN
  dev.mnt.rootdisk.data = sda or mmcblk0

Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I0a58a62d416f966f26b5de04112c2f9a7eceb22c
2022-03-14 16:59:52 -07:00
Juhyung Park
491004bbfb init: mount_handler: detect main block device more reliably
Current code is not portable beyond SCSI devices (e.g., UFS).
For example, eMMC and NVMe devices fail due to their extra postfix.

Change its logic to rewind each character until "queue" directory appears.

Test: Confirm md0p1, sda20, nvme0n1p3, mmcblk0p3 are all handled well.
Change-Id: I585ccf2d4a72f6ef8ecb203acdd72a1e32d3e749
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
2022-03-14 16:59:52 -07:00
Tri Vo
83b58f93a2 trusty: Update TIPC UAPI header
TRUSTY_SEND_SECURE operation was added to Trusty Linux driver by
aosp/1930989.

Bug: 224563842
Test: m libtrusty
Change-Id: Ic922ec177a8d35dba351415ab429216a1931a64d
2022-03-14 16:30:12 -07:00
Akilesh Kailash
6e43216340 Revert "init: Add diagnostics for snapuserd hangs"
This reverts commit 471643a909.

Reason for revert: Given https://r.android.com/1960063, it is safe to revert this diagnostics patch

Change-Id: Ib3600c1982ee10a0204ac0fdbc3e160c2833ed07
2022-03-14 20:49:53 +00:00
Steven Moreland
83785021f7 Merge "libutils: ~RefBase more logs" 2022-03-14 16:59:30 +00:00
Steven Moreland
f164de8935 libutils: ~RefBase more logs
This code was a bit confusing because Android runs with an old debug
mode on. The flag around this is removed to make it more clear what
is going on, and the log is promoted D -> W.

Bug: N/A
Test: boot, check logs
Change-Id: I4645b1a7b8e252336a6f9482ce6b57e1b907619d
2022-03-11 02:46:31 +00:00
Shikha Malhotra
927d9d1c68 Merge "Adding project_id ranges for internal app and cache folders." 2022-03-10 21:58:40 +00:00
David Anderson
b738b7d23a Merge "fs_mgr: Add force_super_partition bootconfig option to avoid slot suffixing alternate super partition names." 2022-03-10 04:42:20 +00:00
Treehugger Robot
5520cb3309 Merge "Adding libutils owner smoreland@ as fuzz targets owner for alerts" 2022-03-08 21:33:05 +00:00
Anis Assi
e75dd9a1c1 Adding libutils owner smoreland@ as fuzz targets owner for alerts
Bug: 221891733
Change-Id: I85ff5c754fb2eb85331e84b3dbacd24844d54efc
2022-03-08 19:48:21 +00:00
Akilesh Kailash
ca0c5c5b10 Merge "If there an error, cqe field is not allocated by io_uring_wait_cqe(); return the error immediately." 2022-03-08 08:07:14 +00:00
David Anderson
5c007a51dd Merge "init: Add diagnostics for signalfd epoll failures." 2022-03-08 08:02:39 +00:00
Treehugger Robot
d2a27913a9 Merge "Set '%c' in LLVM_PROFILE_FILE for continuous mode" 2022-03-08 06:37:02 +00:00
Akilesh Kailash
c08037b2c2 If there an error, cqe field is not allocated by io_uring_wait_cqe(); return
the error immediately.

Bug: 223308671
Test: OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ib485bb767ad58e6a0849fb2431b563e6e7f04cfd
2022-03-08 06:14:22 +00:00
David Anderson
0fa7c40c4c init: Add diagnostics for signalfd epoll failures.
Bug: 222441619
Test: inject failure with close, check for log messages
Change-Id: Ia18b88841779e230d00a6c47aaed4952b1444f85
2022-03-07 21:10:40 -08:00
Treehugger Robot
b74e5af4bd Merge "Add libvndksupport-tests to TEST_MAPPING" 2022-03-08 03:44:46 +00:00
David Anderson
8c7cbf01a9 Merge "init: Skip interface duplicates if service is an override" 2022-03-08 02:56:09 +00:00
Treehugger Robot
f718707191 Merge "Remove dead non-proto tombstone reporting code." 2022-03-08 02:37:46 +00:00
Peter Collingbourne
a6fac881b2 Remove dead non-proto tombstone reporting code.
Bug: 197981919
Change-Id: I58a98070198ef0b686229bd54f87b9073df12d66
2022-03-07 17:03:18 -08:00
Jiyong Park
94bddf13e8 Add libvndksupport-tests to TEST_MAPPING
Bug: 208849199
Test: atest libvndksupport-tests, watch TH
Change-Id: I9617601d642b9f45f142c6bb483d6edf720566b6
2022-03-08 09:53:55 +09:00
Alexander Koskovich
e5f05202c7
init: Skip interface duplicates if service is an override
These aren't actually duplicate interfaces because we
are overriding the service so interfaces in the original
definition will never be used.

Test: Verify 'm dist' works without complaining about
      duplicate interfaces.

Change-Id: Iab5e1d8bb4cb7d5b2608028c3cee73af94c47424
2022-03-07 17:07:05 -07:00
Juhyung Park
852111eea4 init.rc: use /sys/class/block instead of /sys/devices/virtual/block
/sys/class/block covers all of dm-[0-9], sd[a-z], mmcblk[0-9].
Use it instead of /sys/devices/virtual/block, which only covers dm
devices.

This allows f2fs tunings to be applied more reliably regardless of
how the userdata partition is set up.

Do note that while everything under /sys/devices/virtual/block are
expected to have correct SELinux labels by AOSP, some under
/sys/class/block are not as it's symlinked to platform-specific paths,
and it is up to the vendors to label them correctly.

Test: Confirm entries under /dev/sys aren't dangling and cp_interval,
      gc_urgent_sleep_time, iostat_enable and discard_max_bytes are
      all set up properly under FBE, FDE and unencrypted.
Change-Id: I089af5bc068445f33919df6659671e50456d49f9
Signed-off-by: Juhyung Park <qkrwngud825@gmail.com>
2022-03-06 00:31:20 -08:00
Treehugger Robot
5acf7ceb93 Merge "Update shell_and_utilities docs for T." am: 28f4f37161
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2008539

Change-Id: I9cac8b6d8ddb7400e8e3ea9328b722c905c78aff
2022-03-05 21:53:49 +00:00
Treehugger Robot
28f4f37161 Merge "Update shell_and_utilities docs for T." 2022-03-05 21:29:52 +00:00
Elliott Hughes
fe3af716e4 Update shell_and_utilities docs for T.
Change-Id: I5a1aedebe558ad8deafb13933df437b6bb9eb2f2
2022-03-05 08:12:29 -08:00
Pirama Arumuga Nainar
9868487540 Set '%c' in LLVM_PROFILE_FILE for continuous mode
Bug: http://b/194128476

If CLANG_COVERAGE_CONTINUOUS_MODE is set, enable continuous mode by
adding '%c' to LLVM_PROFILE_FILE.

Test: CLANG_COVERAGE_CONTINUOUS_MODE m and verify continuous mode works.
Change-Id: I8ace01f2aeaef62857e73308b04a535739171b53
2022-03-04 12:47:55 -08:00
Treehugger Robot
b5cb068945 Merge "Reserve a UID for AID_SDK_SANDBOX" am: 1821237a1e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2006072

Change-Id: Ibca7c4b1f035f1c5ea9dd8c93310860b0edba3a1
2022-03-04 20:01:01 +00:00
Treehugger Robot
1821237a1e Merge "Reserve a UID for AID_SDK_SANDBOX" 2022-03-04 19:39:58 +00:00
Hanna Nizhnikava
b4c15f5db8 Merge "Create utility method for converting sdk_sandbox_uid to app_uid" am: 4dc57edc1d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2007910

Change-Id: Icc922fe2cac66a1a2ff1cf3e33eaf39b02a40ae0
2022-03-04 11:56:26 +00:00
Hanna Nizhnikava
4dc57edc1d Merge "Create utility method for converting sdk_sandbox_uid to app_uid" 2022-03-04 11:27:40 +00:00
Elliott Hughes
d349650f07 Merge "Define AIDs for Weaver, Keymint and IdentityCredential applets." am: d07d694175
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2002211

Change-Id: I9a250ea7e084a9b87807ce75e2590446c3188e35
2022-03-04 02:05:29 +00:00
Dmitri Plotnikov
8303dd695f Reserve a UID for AID_SDK_SANDBOX
Bug: 219080829
Bug: 219077358
Test: N/A
Change-Id: Iddc4e29668e7d6f2490b5d6acb9b4e5f0082d064
2022-03-03 18:03:30 -08:00
Elliott Hughes
d07d694175 Merge "Define AIDs for Weaver, Keymint and IdentityCredential applets." 2022-03-04 01:40:37 +00:00
Bart Van Assche
b055fb1b38 Merge changes I4b9b76c9,I6f329491,I9c783193,I0798cc94 am: 40080208c1
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2004800

Change-Id: If7eb1e10bdd07a33f6ae37f70d520d15618ff32f
2022-03-03 22:15:06 +00:00
Hanna Nizhnikava
fb78816593 Create utility method for converting sdk_sandbox_uid to app_uid
Method is needed for further use in statsd mapping process.

Bug: 217695033
Test: atest installd_service_test
Change-Id: I508a58da5f8d2e32264002db515425134d18aece
2022-03-03 21:49:43 +00:00
Bart Van Assche
40080208c1 Merge changes I4b9b76c9,I6f329491,I9c783193,I0798cc94
* changes:
  healthd: Convert multiple private methods into static nonmember functions
  healthd: Fix readFromFile()
  healthd: Make initHealthInfo() easier to read
  healthd: Improve readability of BatteryMonitor::init()
2022-03-03 21:18:17 +00:00
Bart Van Assche
095c944b48 healthd: Convert multiple private methods into static nonmember functions
The private methods in class BatteryMonitor do not use the 'this'
pointer. Hence convert these into static nonmember functions.

Test: Compile-tested only.
Change-Id: I4b9b76c9697f1db894ba9fb939ce096ee6b7ff3b
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-03 18:46:12 +00:00
Bart Van Assche
5a7e5083e6 healthd: Fix readFromFile()
Not all readFromFile() callers pass an empty string. Make sure that
readFromFile() returns 0 (failure) if the *buf argument is not empty and
if reading fails.

Fixes: 3217c5c7d9 ("batterymonitor: simplify readFromFile and use std::string buffers")
Test: Compile-tested only.
Change-Id: I6f329491f8aa4a6d378eb7c3cbc17038eb6aa64d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-03-03 18:46:12 +00:00