Commit graph

84753 commits

Author SHA1 Message Date
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
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
Akilesh Kailash
91161042b7 Merge "Disable partition verification when device boots on snapshot" into main 2023-11-15 05:14:50 +00:00
Christopher Ferris
f5a0639899 Merge "Update to support new shared_ptr returns." into main 2023-11-15 01:02:58 +00:00
Akilesh Kailash
889a5d23af Disable partition verification when device boots on snapshot
No need partition verification when device boots on snapshot without
slot switch.

This also saves couple of seconds of boot time.

Bug: 299011882
Test: Boot device on snapshot, OTA on Pixel
Change-Id: I5b781de7e0f745bbfe9646f88ca912139b2d853e
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-11-14 16:58:59 -08:00
Daniel Zheng
b119efef47 Merge "libsnapshot: update offset functions" into main 2023-11-14 23:00:23 +00:00
Daniel Zheng
59ce7a45d1 libsnapshot: update offset functions
Since these functions are used across both parser and writer, updating
it as inline functions in cow_format.

Test: cow_api_test
Change-Id: I9824684e3b9b48947accce935335d4019d745ae0
2023-11-14 12:40:12 -08:00
Daniel Zheng
3200697586 Merge "libsnapshot: resume_point_count" into main 2023-11-14 20:39:42 +00:00
Daniel Zheng
9270152900 Merge changes I19568d11,I08204e2d into main
* changes:
  libsnapshot: update FindResumeOp type
  libsnapshot: v3 writer GetCowSize
2023-11-14 20:30:19 +00:00
Akilesh Kailash
41305c3870 Merge "libsnapshot: Check if OTA update in progress during reboot" into main 2023-11-14 20:14:57 +00:00
Treehugger Robot
b37d7cbef8 Merge "Attempt process kill even if cgroup is already removed" into main 2023-11-14 20:10:34 +00:00
Kelvin Zhang
109932146d Attempt process kill even if cgroup is already removed
Test: th
Bug: 308900853
Change-Id: I21ae5bacf4a25cc06a1fd47e2aadbf5ae22661a7
2023-11-14 11:13:28 -08:00
Akilesh Kailash
f1f06f8678 libsnapshot: Check if OTA update in progress during reboot
If any of the read-only partitions are mounted off dm-user
then certainly update is in-progress.

Bug: 308900853
Test: OTA on Pixel, reboot during OTA.
Change-Id: I36121e1d99ec7c1f1110a65fc67996190875af18
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-11-14 16:04:17 +00:00
Daniel Zheng
f897650f6e libsnapshot: resume_point_count
We want to add a resume_point_count in the header to represent how many
resume points we've written. In the case that we've written less than
resume_buffer_size, we only want to read the valid resume points.

without these changes incremental OTA runs into segfault or have faulty
data when trying to FindResumeOp() as our resume points contain invalid
entries

Test: full ota followed by inc ota on cuttlefish
Change-Id: I0a8971955439639f2d0f39d9d518c1145ae15c3d
2023-11-13 15:57:25 -08:00
Daniel Zheng
a503453767 libsnapshot: update FindResumeOp type
Update FindResumeOp to take in a uint64_t to match the value of the
caller function

Test: ota with following CL
Change-Id: I19568d119b7ebd75ea9e98970b311ae7da92ff0e
2023-11-13 15:57:24 -08:00
Daniel Zheng
c1a18756dc libsnapshot: v3 writer GetCowSize
Cow size should just be wherever the last data position is written. In
v3 we no longer have a footer, so this calculation is simple. This
function is used by cow estimator

Test: cow_api_test
Change-Id: I08204e2d560b120450019a529baa41de9b8e66d5
2023-11-13 13:17:50 -08:00
Daniel Zheng
e343580f72 Merge "libsnapshot: update cow estimation" into main 2023-11-13 18:13:09 +00:00
Daniel Zheng
a4f80e5ca3 Merge "libsnapshot: implement resume buffer" into main 2023-11-13 18:13:01 +00:00
Elliott Hughes
dbb4a11156 Merge "run-as: remove a special case." into main 2023-11-13 15:43:37 +00:00
David Anderson
06f29501c7 Merge "libsnapshot: Add a test case for recent decompress regression." into main 2023-11-11 04:03:18 +00:00
David Anderson
92b29e1925 libsnapshot: Add a test case for recent decompress regression.
The attached test data is a 4096 length byte run that gz compresses to
exactly 4096 bytes. This exposes an edge case in CowReader::ReadData
with v2 snapshot files.

Bug: 310191184
Test: cow_api_test
Change-Id: I35e8d7e939d607d1dc118285ebc2f636c2291a20
2023-11-11 00:29:41 +00:00
Elliott Hughes
84e41ca0e2 run-as: remove a special case.
This is a change for some system apps that have /data/user_de/0/ in the
package list, but it's easier to reason about and more consistent to
always go down the same path.

Bug: http://b/308990322
Test: treehugger
Change-Id: I479485655c61e8a31fb23f779c66d54b0bb476c0
2023-11-10 22:02:00 +00:00
Christopher Ferris
1503890fc6 Update to support new shared_ptr returns.
Bug: 309857311

Test: All unit tests pass.
Change-Id: Ia44ebeb558d3d1101ab63b064731656f0f89c487
2023-11-10 00:05:49 -08:00
Daniel Zheng
79a68a934b libsnapshot: update cow estimation
Cow estimator needs to update next_data_pos_ to be in the correct
position

Test: th
Change-Id: I1e3f2c9434573197e840be5637a90c679610ac4e
2023-11-09 15:49:15 -08:00
Daniel Zheng
c2ce084889 libsnapshot: implement resume buffer
Add resume space to cow v3. Resume buffer goes after header and scratch
space, and is currently set to contain 4 resume points. When AddLabel is
called, the oldest label is replaced with newest one.

Parser will parse up until the last resumable op from a given label.

Test: cow_api_test
Change-Id: Ie072f245721776887d59c96dad296965ad31a5cc
2023-11-09 15:48:42 -08:00
Daniel Zheng
0ac91e1f02 Merge "libsnapshot: add compatibility check" into main 2023-11-09 19:38:18 +00:00
Daniel Zheng
04ca59d6ff libsnapshot: add compatibility check
Ensure that cow was written by v3 writer for the data_length check to
work. All ops written by v2 writer should go through the decompressor
path if a compressor was used.

Test: cow_api_test
Change-Id: I053d6fdaf29ef7001e68f43b45d5a3ff1a36b1c3
2023-11-09 11:32:02 -08:00
Elliott Hughes
ec63f6f10a Merge "run-as: remove unecessary code." into main 2023-11-09 16:00:51 +00:00
Treehugger Robot
c3ef20c326 Merge "Updated liblp fuzzers." into main 2023-11-09 10:02:11 +00:00
Christopher Ferris
580e728696 Merge "debuggerd_test: Scale timeouts by HwTimeoutMultiplier" into main 2023-11-09 01:41:35 +00:00
Mattias Simonsson
38ab045342 debuggerd_test: Scale timeouts by HwTimeoutMultiplier
Timeouts in tombstoned.cpp and intercept_manager.cpp are scaled
by HwTimeoutMultiplier, but the timeouts in debuggerd_test.cpp
are not, which means the CrasherTest#intercept_timeout test will
fail for any platform that has a high enough HwTimeoutMultiplier.

Bug: 309532789
Test: debuggerd_test.CrasherTest#intercept_timeout
Change-Id: I83cd01e87644c011efa155a32fd5d92cc8a43a95
2023-11-08 14:56:48 -08:00
Akilesh Kailash
14270410cf Merge "init: Start snapuserd_proxy after early-init" into main 2023-11-08 20:37:28 +00:00
Elliott Hughes
d291d68c4c run-as: remove unecessary code.
We haven't had a symlink here for many years, so there's no reason to
allow one any more.

Test: treehugger
Change-Id: Ic10d547a88fc6d9c442a5dfb228c5914ea48a32d
2023-11-08 10:46:51 -08:00
Elliott Hughes
1b86c0dd7d Merge "run-as: reduce the scope of changed egid." into main 2023-11-08 16:02:33 +00:00
Akilesh Kailash
76b553c93b init: Start snapuserd_proxy after early-init
When service is started prior to early init and if per-app memcg is enabled, service start will fail as the required directories for memcg isn't present viz /dev/memcg/apps.

Bug: 308818430
Test: th and CF OTA test with per-app memcg enabled
Change-Id: Ic65e8d179fbfb8e2135f2de5cc7c77d6c29ea7d2
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-11-08 15:07:57 +00:00
Daniel Zheng
5e83e63bd7 Merge "libsnapshot: Add single threaded compression to v3 writer" into main 2023-11-08 05:41:09 +00:00
Treehugger Robot
7d1f582d36 Merge changes I5e259fdd,I5b9ab456 into main
* changes:
  init: Make WaitToBeReaped() wait less long
  init: Create different file descriptors for SIGCHLD and SIGTERM
2023-11-08 01:35:58 +00:00
Elliott Hughes
bfc115311e run-as: reduce the scope of changed egid.
There's no bug here that I can see, but having a larger than necessary
scope just seems like a bad idea in case anyone adds anything later.

Also switch to modern struct initialization syntax.

Bug: http://b/308990322
Test: treehugger
Change-Id: If2576f902de62e8c24d4a643c224df8ea6cff5d5
2023-11-07 14:46:25 -08:00
Daniel Zheng
e363841e75 libsnapshot: Add single threaded compression to v3 writer
Add compression path back into Cow operations. Main change is that the
compression algorithm is stored in the header instead of each individaul
op. Have the writer_v3 set this algorithm when parsing options.

There looks to be a lot of code we'll be able to factor out into the
base class, but we can leave that to a later CL.

Test: cow_api_test
Change-Id: Ie9a8eceb5fbdaecae50911119c75f2e51d776a28
2023-11-07 14:28:57 -08:00