Commit graph

84791 commits

Author SHA1 Message Date
Treehugger Robot
0ca4e8f4b4 Merge "service_test: Test stopping services after migration to another cgroup" into main 2023-11-28 00:14:31 +00:00
Treehugger Robot
57359b731e Merge "libprocessgroup: Stop services that have been migrated to another v2 cgroup" into main 2023-11-27 23:23:12 +00:00
Bart Van Assche
86a2ae28e6 service_test: Test stopping services after migration to another cgroup
The root cause of "After OTA, device is not responding" is that
Service::Stop() did not stop services that had been migrated to another
v2 cgroup. Add a unit test for that scenario.

Bug: 308900853
Change-Id: I590fde90e31326290c2c8ce8fce51e94b215a979
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-27 14:27:02 -08:00
Bart Van Assche
a43b96c157 libprocessgroup: Stop services that have been migrated to another v2 cgroup
CL 2828279 doesn't do what it's description says that it does. Making
Service::Stop() work for processes that have been migrated to another v2
cgroup requires changing DoKillProcessGroupOnce(). Hence this CL that
removes the early return statements from DoKillProcessGroupOnce().

Bug: 308900853
Change-Id: Ib798555feeb95a786a619c3d7013c7d5829b01ad
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-27 14:13:46 -08:00
Yi-Yo Chiang
455fb82bf9 Merge "fs_mgr_overlayfs: De-dup common methods" into main 2023-11-27 11:16:51 +00:00
Yi-Yo Chiang
16239ad862 fs_mgr_overlayfs: De-dup common methods
Keep only one copy of GetBootScratchDevice().

Bug: 306124139
Test: build
Change-Id: I11603566ab454eb028b50873d66f4ab967b204f9
2023-11-27 11:16:41 +00:00
Yi-Yo Chiang
475599f5c5 Merge "second-stage-init: Don't move submounts when mounting overlayfs" into main 2023-11-27 11:16:24 +00:00
Yi-Yo Chiang
28113cf3f6 second-stage-init: Don't move submounts when mounting overlayfs
Right now there is a bug in second-stage-init that screws up the
overlayfs overrides. This happens because:
1. second-stage-init mount_all might be executed in the "bootstrap"
   mount namespace.
2. In order to move (MS_MOVE) submounts in fs_mgr_overlayfs_mount_all(),
   we change the mount propagation type of overridden filesystems to
   MS_PRIVATE.
3. This means that the "default" mount namespace would not receive the
   mount events of the overlayfs overrides.
4. After /data is mounted, init would switch to the "default" namespace.
   This means any new processes spawned after this period would not be
   able to see the overlayfs overrides.

We fix this by changing the mount order of second-stage-init mount_all
to mount the overlayfs override of a partition immediately after the
partition is mounted. This way we don't need to move any submounts as
there can't be any, thus we don't need to set any mountpoint to
MS_PRIVATE so the mount event of the overlayfs would be propagated to
the "default" mount namespace, too.

Bug: 309407859
Bug: 306124139
Test: adb-remount-test
Test: verify that overlayfs tookover successfully from second-stage-init
Change-Id: If2ff4852516292ccbc7abdeebe0e9a7c1c7ba606
2023-11-27 17:16:40 +08:00
Treehugger Robot
bc907c00f4 Merge "Add exfat fs in fs_mgr" into main 2023-11-24 10:55:29 +00:00
yanxu
3f9f595067 Add exfat fs in fs_mgr
Need to support exfat fs type point mount in recovery mode

Bug:312674538
Test: SIU (Apply update from SD card) in recovery mode

Change-Id: I2735e5068c47b183a25d2305bca89f08de1e32c7
2023-11-24 10:26:59 +00:00
Treehugger Robot
dfe6c802d0 Merge "init: Fix signalfd support in WaitToBeReaped()" into main 2023-11-22 18:06:48 +00:00
Bart Van Assche
1daf88d6ce init: Fix signalfd support in WaitToBeReaped()
Add an Epoll::Open() call such that the Epoll::Wait() calls wait for the
signalfd. Rename DiscardSiginfo() into HandleSignal(). Handle Epoll method
call failures. Test whether alive_pids is empty once per loop iteration.

Test: CtsInitTestCases:ServiceStopTest
Change-Id: I16c27aa74d61f889b304f3e59cd3c5255c299ce1
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-22 09:06:02 -08:00
Treehugger Robot
c93c5eff0e Merge "init: Introduce the function ReapAndRemove()" into main 2023-11-22 02:52:44 +00:00
Daniel Zheng
1056a1172a Merge "libsnapshot: add sequence data" into main 2023-11-21 22:31:57 +00:00
Kelvin Zhang
06d80246c8 Merge "Make RemoveCgroup idempotent" into main 2023-11-21 21:05:43 +00:00
Daniel Zheng
43aeb22858 libsnapshot: add sequence data
v3 writer to write sequence data. Sequence data will be written after
the scratch space and before the resume space. Since this is just a list
of integers, writing and reading should be trivial

Test: cow_api_test
Change-Id: If3b6b1cfa155aeb65bf693263fc373154ba8e81d
2023-11-21 09:50:16 -08:00
Daniel Zheng
d2d7a1ff0e Merge changes I56a0d747,I1585601a,I9e44330e into main
* changes:
  libsnapshot: move header op count setup
  libsnapshot: sync header metadata
  libsnapshot: update variable name
2023-11-21 17:49:29 +00:00
Bart Van Assche
9c6b723adb init: Introduce the function ReapAndRemove()
Prepare for adding a second caller of ReapAndRemove().

Change-Id: I0f54af6136f49caa0198c123a4c8de968e5f41ba
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-21 09:16:50 -08:00
Yi-Yo Chiang
7f322bcaf0 Merge changes I12bc2ccd,I8174257c into main
* changes:
  fs_mgr_overlayfs: Fix "/" mount propagation type after remount
  fs_mgr_overlayfs: Fix submount propagation type after remount
2023-11-21 09:36:47 +00:00
Daniel Norman
97807f53ef Merge "Assigns system user/group to /dev/hidraw* devices." into main 2023-11-21 02:10:09 +00:00
Treehugger Robot
2e2e836a89 Merge "Use vendor/etc/ueventd.rc on microdroid" into main 2023-11-21 02:03:16 +00:00
Inseob Kim
52d8fe9b04 Use vendor/etc/ueventd.rc on microdroid
... because vendors should be able to extend ueventd.rc for their own
devices (in microdroid) and microdroid's system.img can't be amended.

Bug: N/A
Test: boot microdroid
Change-Id: I7ceaf3f87453c8e29f9d9bf03d4d1866185d4fec
2023-11-21 10:05:49 +09:00
Daniel Zheng
209fda3562 libsnapshot: move header op count setup
Op count should be set before we sync the header. This way subsequence
writers can initialize with the correct op buffer size

Test: cow_api_test
Change-Id: I56a0d747b3f2a1d9d582d8f9d643b81cbdd9b8d7
2023-11-20 11:53:21 -08:00
Daniel Zheng
763776435d libsnapshot: sync header metadata
After we write emit a label, we need to update the number of resume
points + sequence data and op_count. Realistically we could just call
Finalize, but maybe synching these specific fields could prevent
unexpected outcomes.

Test: cow_api_test
Change-Id: I1585601a134221689ce8d5675a2a3e32f1e8a0e6
2023-11-20 11:53:20 -08:00
Daniel Zheng
5d30009a7e libsnapshot: update variable name
updating name to count rather than buffer size

Test: cow_api_test
Change-Id: I9e44330e7a230b5ab5f5e914ef74a63cc4ebaa61
2023-11-20 11:40:36 -08:00
Treehugger Robot
142f8129ec Merge "init: Combine two global sigchld_fd variables into one" into main 2023-11-20 19:18:39 +00:00
Daniel Zheng
bc518418c7 Merge "libsnapshot: update resume offset calculation" into main 2023-11-20 18:54:19 +00:00
Treehugger Robot
558fd9ab7a Merge "Add StrongPointer::release()" into main 2023-11-20 18:27:15 +00:00
Bart Van Assche
97047b54e9 init: Combine two global sigchld_fd variables into one
Remove the Service::SetSigchldFd() method. Make the Service::GetSigchldFd()
create a signalfd for SIGCHLD. This makes it possible to use a SIGCHLD
signalfd in unit tests.

Change-Id: I0b41caa8f46c79f4d400e49aaba5227fad53c251
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-20 09:32:59 -08:00
John Reck
e01550bbb6 Add StrongPointer::release()
Useful when dealing with raw pointers in unavoidable places. Avoids
an awkward (and "slow") dance of mySp->incStrong(0); mySp->get(); ~mySp;

Test: make && atest --host libutils_binder_test
Change-Id: Ib8d46150592725cc256779bccfed19a16dce78b2
2023-11-20 11:55:02 -05:00
Daniel Zheng
95cc6b6f01 libsnapshot: update resume offset calculation
Update resume offset calculation to use function call

Test: cow_api_test
Change-Id: I7a9a86dc007110d02d889d1e59b24c3068b8d9e9
2023-11-20 03:30:40 -08:00
Bart Van Assche
ced62e53ed Merge "Revert "libprocessgroup: Add a function to remove only empty process groups"" into main 2023-11-18 17:02:44 +00:00
Christopher Ferris
d1067b3f0c Merge "Avoid crashing on bad architecture value." into main 2023-11-18 00:07:03 +00:00
Bart Van Assche
3048812055 Revert "libprocessgroup: Add a function to remove only empty process groups"
Revert this CL because it tests whether or not cgroup.procs files are
empty with the stat() system call and because the cgroup filesystem
always reports st_size == 0. Rename RemoveUidCgroups() into
RemoveEmptyUidCgroups().

Change-Id: I4de6f16c814c4b47d8d74c8045f0c1ee71975ac0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-17 14:28:30 -08:00
Christopher Ferris
c7cc571fa1 Avoid crashing on bad architecture value.
The only way to get a bad architecture value in the protobuf is if
the data was corrupted or an unsupported architecture was added without
the register support.

If the protobuf is corrupted, this is strictly better since it
still produces a tombstone with the data present.

If there is an unsupported architecture, it will still result in a tombstone,
only the registers would not be present. It would also be very obviously
a problem that needs to be fixed. Again, this is strictly better since
the crash in generation is not necessarily visible unless you look at
the log. Here, the data is in the log and in the tombstone.

This also removes the only dependency in this file on the async_safe
library.

Test: Ran unit tests.
Test: Forced an invalid architecture and verified tombstone is present
Test: with error message, and error message printed in the log.
Change-Id: I8e4a2e3f778fafb5b7241c2f23d5f867f1341ed8
2023-11-17 22:12:14 +00:00
Kalesh Singh
72d8882153 Merge "x86_64: mmap rnd bits: Allow min bits of less than 32" into main 2023-11-17 21:23:26 +00:00
Bart Van Assche
6ebc14d97f Merge "Migrate the blkio controller to the v2 cgroup hierarchy" into main 2023-11-17 20:34:24 +00:00
Jaegeuk Kim
389c03d4c8 Merge "Use the dm target for userdata" into main 2023-11-17 20:26:00 +00:00
Treehugger Robot
c049af4e37 Merge "libprocessgroup: Reject JoinCgroup actions for v2 controllers" into main 2023-11-17 20:23:03 +00:00
Bart Van Assche
f99ca8aeb1 Migrate the blkio controller to the v2 cgroup hierarchy
There are multiple use cases in Android for which background writes need
to be controlled via the cgroup mechanism. The cgroup mechanism can only
control background writes if both the blkio and memcg controllers are
mounted in the v2 cgroup hierarchy. Hence this patch that migrates the
blkio controller from the v1 to the v2 cgroup hierarchy.

The changes compared to the previous version of this CL are as follows:
- The JoinCgroup actions for the "io" controller have been left out
  since these caused processes to be migrated to the v2 root cgroup.
- The BfqWeight / CfqGroupIdle / CfqWeight settings have been included
  in this CL instead of applying these settings as a separate CL.

Change-Id: I67e06ce3462bb1c1345dba78f8d3d655b6519c74
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-17 11:37:24 -08:00
Bart Van Assche
2953a9273e libprocessgroup: Reject JoinCgroup actions for v2 controllers
A JoinCgroup action for a v2 cgroup controller migrates a process or task
from the uid_%d/pid_%d cgroup into another cgroup, e.g. the root cgroup.
This may make services unkillable because Service::Stop() only stops a
service if the uid_%d/pid_%d cgroup still exists when Service::Stop() is
called.

Bug: 309674654
Change-Id: I20b797afdf596125ff5a6ed41cb33fe59b84ac88
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-17 11:37:24 -08:00
Treehugger Robot
b190d94469 Merge "libprocessgroup: Make a log message more detailed" into main 2023-11-17 19:10:24 +00:00
Kalesh Singh
24a47eccf7 x86_64: mmap rnd bits: Allow min bits of less than 32
With a regular x86 kernel we are always able to get 32
min bits for mmap randomization.

However to emulate 16KB for x86 app developers the kernel
can only provide 30 bits for the randomization due the to
larger page size (PAGE_SHIFT =+ 2).

Allow the min rand bits to be (32 - (PAGE_SHIFT - 12)) in
order to generically support larger than 4KB page sizes.

This should be a no-op change for all devices, except the
x86 16KB emulator, since they will always be able to get
32 random bits.

Bug: 309816695
Test: Boot test 4k x86 device
Test: Boot test emulated 16k x86 device
Change-Id: I48d47d56ac3aecb71a9e0093a7033bb60b89c2b7
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-11-17 11:02:04 -08:00
Jaegeuk Kim
90703b86d9 Use the dm target for userdata
Framework or applications can try to find userdata dm target from "/proc/mounts"
which gives "/dev/block/mapper/userdata".

That causes breaking the assumption in all the places.

Bug: 311165039
Change-Id: I9ea1b4589cdd52021d9807f7240c2e4b6d6d05ef
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2023-11-17 10:39:03 -08:00
Bart Van Assche
df98534e19 libprocessgroup: Make a log message more detailed
For log messages like the following it is not possible to derive why
this message has been logged:

E libprocessgroup: AddTidToCgroup failed to write '3949'; fd=55: Operation not supported on transport endpoint

Hence include the cgroup path and the tid type in the log message.

Change-Id: I057711fe576b82f6454456b7284186ddeece33c3
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-11-17 10:11:20 -08:00
Jaegeuk Kim
191af79538 Merge "Use target device mapper given mapper target" into main 2023-11-15 22:40:45 +00:00
Jaegeuk Kim
a720fe785c Use target device mapper given mapper target
Let's translate /dev/block/mapper for dm libs.

Bug: 311084775
Change-Id: I23666c5590a15652192e004e1990edd73b7a8df8
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2023-11-15 13:08:39 -08:00
Kelvin Zhang
459edb0bd0 Make RemoveCgroup idempotent
When attempting to remove a cgroup, a ENOENT means this cgroup is
already removed. Treat such errno as success for idempotency.

Test: th
Bug: 308900853
Change-Id: I6ef3c25f03d185194205b3845784d284fdc4d444
2023-11-15 08:39:41 -08:00
Akilesh Kailash
91161042b7 Merge "Disable partition verification when device boots on snapshot" into main 2023-11-15 05:14:50 +00:00
Daniel Norman
e4f981dce0 Assigns system user/group to /dev/hidraw* devices.
This allows system_server to access these devices.

Note: This also matches existing ueventd rules used by any
device which followed the Sensor HAL's dynamic sensor README.

Bug: 303522222
Test: ls -l /dev/hidraw0
Change-Id: I0830aca77422d6cab64af05dba1554667737760c
2023-11-15 03:04:07 +00:00