Commit graph

80920 commits

Author SHA1 Message Date
Daniel Zheng
1e6456b011 Cleaned up slot logic
Updating old clean up slot logic change. Some devices don't know current
slot so we can't always just call get_current_slot()

Test: tested flashall on raven
Change-Id: Id655f1c1ee0b1ff09331f0d91d77412836d0af8d
2023-04-10 09:35:48 -07:00
Treehugger Robot
57c1a4e308 Merge "Improve the formatting for init's README." 2023-04-07 00:49:23 +00:00
Mateus Azis
1a2f73d76a Improve the formatting for init's README.
Make sure the arguments to "mkdir" show up in the same block.

Before: c3a119caa3/init/README.md
After: https://android.googlesource.com/platform/system/core/+/refs/changes/60/2528060/1/init/README.md

Test: N/A
Change-Id: I88b4931e70e2793566cce53c38c0295168463971
2023-04-06 13:46:35 -07:00
Thiébaud Weksteen
c3a119caa3 Merge "Skip newlines for SELinux logs" 2023-04-05 23:37:51 +00:00
Kevin Jeon
2a70a7432c Merge "Add pointer dereference in debuggerd error msg" 2023-04-05 22:34:51 +00:00
Kevin Jeon
06af624e66 Add pointer dereference in debuggerd error msg
This change adds a missing pointer dereference to the InterceptResponse
when checking for a size mismatch.

Test: build
Bug: N/A
Change-Id: I88afed6f1c0f33fe237d337b0fb8fc0a0c0e3bac
2023-04-05 16:32:39 -04:00
Thiébaud Weksteen
f03dde8549 Skip newlines for SELinux logs
libselinux log messages usually end with a new line character. Android
log system does not require the new line character and will include the
character as-is in the log buffer.

This trimming was already implemented when the message is typed as
SELINUX_AVC (see SelinuxAvcLog). Move the truncation one level up so it
is occurring for all types of logs.

Test: boot & adb logcat & inspect SELinux logs
Change-Id: I360359c1b178ef24d555dd41f8d4a18b293a175c
2023-04-05 09:32:18 +10:00
Treehugger Robot
b2fdbef489 Merge "Revert "Cleaned up some slot logic"" 2023-04-03 21:49:25 +00:00
Kelvin Zhang
2a4a45f3e4 Revert "Cleaned up some slot logic"
This reverts commit bd85a18d0b.

Reason for revert: b/276759363

Change-Id: I3ba08cf4abeeb7769569512d50e7ff135438cf20
2023-04-03 20:44:05 +00:00
Treehugger Robot
6fac9acf2c Merge "Allow libmodprobe to be used by host binaries" 2023-04-01 03:49:04 +00:00
Treehugger Robot
1c324d3559 Merge "Handle with the nonnull case in a tricky way" 2023-04-01 02:46:24 +00:00
zijunzhao
fa8037c207 Handle with the nonnull case in a tricky way
The func readdir() is not allowed to pass a nullptr.
Bug: b/245972273
Test: mm

Change-Id: Idbb3f552b026dc6d727886d22989d3359ed6633b
2023-03-31 23:50:37 +00:00
Daniel Zheng
b16aba889a Merge "Cleaned up some slot logic" 2023-03-30 21:49:15 +00:00
Daniel Zheng
719caca725 Merge "Added some error logs to wipe" 2023-03-30 21:30:11 +00:00
Daniel Zheng
4aa47338f2 Merge "Added check to copy AVB footer" 2023-03-30 18:24:31 +00:00
Daniel Zheng
bd85a18d0b Cleaned up some slot logic
Doesn't look like we actually need current_slot, since we can always
just call function get_current_slot

Test: tested flashall on raven
Change-Id: Icba64bc9fdd08f36d44965e32558a73d0beab0e1
2023-03-30 18:21:28 +00:00
Daniel Zheng
6f213b2c79 Added some error logs to wipe
Changed so if we call wipe on a partition that doesn't exist we'll get
some helpful error messages.

Test: tested wipe test
Bug: 194686221
Change-Id: I19dc0396a7a98d0b2be7859edbffeb8acdc9850a
2023-03-30 18:19:04 +00:00
Daniel Zheng
e33e8a8685 Added check to copy AVB footer
is_logical shouldn't work in bootloader for some devices, so we also need to check
using should_flash_in_userspace to see if partition is dynamic

Test: tested to flash {partition} on raven and checked to see avb
footers are not copied from dynamic partitions

Change-Id: Iabb3ea535fa80b26cf1c08040beb3d4ea5e8c2ae
2023-03-30 18:19:04 +00:00
Kelvin Zhang
bdd595f0f9 Allow libmodprobe to be used by host binaries
Cuttlefish tooling need libmodprobe to determine if a kernel module is
signed.

Bug: 273752147
Test: th
Change-Id: Icea49802d032b27bd89ed8f0bee1bc4814298774
2023-03-29 15:29:02 -07:00
Mitch Phillips
5a2a302108 Merge "[debuggerd] New protocol to AM to handle recoverable crashes." 2023-03-29 20:28:35 +00:00
Treehugger Robot
c1798def91 Merge "libprocessgroup: Check validity of uid and pid arguments" 2023-03-29 19:49:18 +00:00
Vova Sharaienko
a662169c44 Merge "[TeX] Introduced Telemetry Express Logging APIs" 2023-03-28 22:05:28 +00:00
Treehugger Robot
c631556363 Merge "Updated fuzz_config in Android.bp file" 2023-03-28 04:05:22 +00:00
Lingxue Luo
1295d2e8bb Merge "Add ability to automatically bootup" 2023-03-24 21:41:06 +00:00
Vova Sharaienko
c246440dc5 [TeX] Introduced Telemetry Express Logging APIs
- provided C++ Histogram metric logging API with UID

Bug: 266586106
Test: m
Change-Id: I2ee92d423be5f9c137fa160d8c744340972f8036
2023-03-24 21:39:53 +00:00
Mike McCreavy
5766fe7dee Add ability to automatically bootup
Based on a new system property. This won't change any behavior if that
new system property isn't set.

Ignore-AOSP-First: WearOS specific change

Upstreaming from Wear: b/272526799
Bug: 199404658
Test: set the property, check that off-mode-charging automatically
reboots

(cherry picked from commit 332b3686290af70c73a464ce35b0c1124b2ce831)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:82d8011f170d5b1c936d117f4fb74836333714b6)
Merged-In: I98f37a840a43cb5216319457027b76fc493e3f62
Change-Id: I98f37a840a43cb5216319457027b76fc493e3f62

NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
0,6 +620,18 @@
         kick_animation(&batt_anim_);
     }
     health_info_ = health_info;
+
+    if (property_get_bool("ro.charger_mode_autoboot", false)) {
+        if (health_info_.battery_level >= boot_min_cap_) {
+            if (property_get_bool("ro.enable_boot_charger_mode", false)) {
+                LOGW("booting from charger mode\n");
+                property_set("sys.boot_from_charger_mode", "1");
+            } else {
+                LOGW("Battery SOC = %d%%, Automatically rebooting\n", health_info_.battery_level);
+                reboot(RB_AUTOBOOT);
+            }
+        }
+    }
 }

 int Charger::OnPrepareToWait(void) {

Original patch:
From 82d8011f170d5b1c936d117f4fb74836333714b6 Mon Sep 17 00:00:00 2001
From: Alice Sheng <alicesheng@google.com>
Date: Fri, 18 Mar 2022 10:25:31 -0700
Subject: [PATCH] Add ability to automatically bootup

Based on a new system property. This won't change any behavior if that
new system property isn't set.

Ignore-AOSP-First: WearOS specific change

Bug: 199404658
Test: set the property, check that off-mode-charging automatically
reboots

Change-Id: I98f37a840a43cb5216319457027b76fc493e3f62
(cherry picked from commit 332b3686290af70c73a464ce35b0c1124b2ce831)
---
2023-03-24 17:22:17 +00:00
Eric Biggers
aa70ac106a Merge "libsparse: fix double free after block splitting" 2023-03-24 00:39:04 +00:00
Eric Biggers
ef4507b6c8 libsparse: fix double free after block splitting
Due to https://r.android.com/1310496, sparse_file_write() splits all
blocks larger than 64 MiB.  However, the code that splits file-backed
blocks copies the pointer to the filename without duplicating the
underlying memory, causing a double free in backed_block_destroy()
later.  Fix this by using strdup().  Also, as long as that is being
fixed, also check for failure.

Test: SANITIZE_HOST=address mmm external/e2fsprogs
      mkdir mnt
      mkfs.ext4 img 1G
      sudo mount img mnt
      sudo cp /dev/urandom mnt/file
      sudo umount mnt
      ext2simg img simg

Before this fix it gave:

    ==2216498==ERROR: AddressSanitizer: attempting double-free on 0x602000000090 in thread T0:
        #0 0x55a52454c9a2 in free out/stage2/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
        #1 0x7ffa247c82ee in backed_block_destroy(backed_block*) system/core/libsparse/backed_block.cpp:106:5
        #2 0x7ffa247c82ee in backed_block_list_destroy(backed_block_list*) system/core/libsparse/backed_block.cpp:124:7
        #3 0x7ffa247cd055 in sparse_file_destroy system/core/libsparse/sparse.cpp:49:3
        #4 0x55a524587b75 in main external/e2fsprogs/contrib/android/ext2simg.c:239:2

Change-Id: I4607ef5adcf6512645342beaf91aff6033414e54
2023-03-23 20:23:00 +00:00
David Anderson
e74976cccd Merge changes Ib90ae553,I3ca3ad9c
* changes:
  RESTRICT AUTOMERGE: snapuserd: Remove DaemonOps.
  RESTRICT AUTOMERGE: snapuserd: Split the server into two classes.
2023-03-23 18:29:40 +00:00
David Anderson
b634c6f527 Merge "Remove unused variable mount_point" 2023-03-23 15:39:49 +00:00
Bart Van Assche
f94035552f Merge "[DO NOT MERGE] Migrate the blkio controller to the v2 cgroup hierarchy" 2023-03-23 13:47:34 +00:00
Ayushi Khopkar
33ff88f9c3 Updated fuzz_config in Android.bp file
Added new fields in fuzz_config like - hotlists,
description, vector, service_privilege, users, fuzzed_code_usage, etc.

Bug: 271384401
Test: Build fastboot_fuzzer

Change-Id: I7799ffcb7f11202711b19cf40e8c05e050d3b519
2023-03-23 16:06:24 +05:30
zhangyongpeng
18b3fda9b7 Remove unused variable mount_point
Since aosp/929692, this variable has been discard.

Test: manual

Signed-off-by: zhangyongpeng <zhangyongpeng@xiaomi.com>
Change-Id: I164766c9af06c0c19bc19b258cb866ed7cf36853
2023-03-23 14:14:21 +08:00
Bart Van Assche
5a3c3f7ccf libprocessgroup: Check validity of uid and pid arguments
A user ID (uid) must be greater than or equal to zero to be valid. Only
strictly positive process IDs are valid. Add argument checks in
libprocessgroup of uid and pid arguments to make it easier to determine
the origin of invalid arguments.

Change-Id: I8a6d96ca4576bc9c329498c6a804dd05a02afca5
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-22 18:35:41 -07:00
David Anderson
369c993f5d RESTRICT AUTOMERGE: snapuserd: Remove DaemonOps.
These are only used for a single switch statement. Just compare the
input strings instead.

Bug: 269361087
Test: builds, ota applies

Change-Id: Ib90ae55309ea99c181585c64ed2ac814e5ed6c72
2023-03-22 19:30:04 +00:00
David Anderson
4983e1d33c RESTRICT AUTOMERGE: snapuserd: Split the server into two classes.
This splits server into two classes: one that handles the IPC requests,
and one that managers snapshot handlers. This will allow embedding of
the snapshot handling code, without booting up a server. It'll also make
testing much easier.

The handler code has been further placed behind a virtual interface,
though this is likely unnecessary unless we start testing the server
logic itself (or attempt to unify the S and T+ versions of snapuserd).

Bug: 269361087
Test: ota
Change-Id: I3ca3ad9c8c1fb910a1c7bf9f44165e2f44c930c9
2023-03-22 19:29:15 +00:00
Bart Van Assche
eef0f563fd [DO NOT MERGE] 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 blkio controller has been marked as optional since not all Android
kernels enable this controller (CONFIG_BLK_CGROUP).

This patch increases the TOTAL_BOOT_TIME for devices with a 4.19 kernel
(redfin) from 18.9 s to 20 s. This patch does not affect the boot time
for devices with a 5.10 or 5.15 kernel.

This patch increases the time spent in CgroupMap::ActivateControllers()
by 25 microseconds in Cuttlefish on an x86-64 CPU.
CgroupMap::ActivateControllers() is called by Service::Start().

Bug: 213617178
Test: Cuttlefish and various phones
Change-Id: I3c07c1be84c3feb277b7d7003652d5d3b57c6541
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-03-22 11:39:53 -07:00
David Anderson
ecdbbbda82 Merge changes Ie68aed2f,Ic40696b3
* changes:
  fastboot: Handle libsparse failures better.
  libsparse: Fix allocation failures on 32-bit systems.
2023-03-22 00:02:13 +00:00
Elliott Hughes
3b1e71c63b Merge "riscv64: fix debuggerd_test build." 2023-03-21 18:56:36 +00:00
Shikha Panwar
e11ab73647 Merge "Add tombstone_handler for crashes in Microdroid" 2023-03-21 18:14:12 +00:00
Elliott Hughes
2077cea07d Merge "riscv64: fix mips-ism." 2023-03-21 16:58:19 +00:00
David Anderson
49cc3f0784 Merge "libsparse: Propagate failures when resparsing files." 2023-03-21 15:48:44 +00:00
Daniel Zheng
bf18673dee Merge changes I82ac2392,Ie0dd7acd,I8018e48f
* changes:
  Updating Flashall to work off tasks
  Updated location of initialization
  Updating FlashTask to require img-name
2023-03-21 01:59:33 +00:00
Vova Sharaienko
0ffaad7007 Merge "[TeX] Introduced Telemetry Express Logging APIs" 2023-03-21 01:14:36 +00:00
Armelle Laine
8a42990cc6 Merge "trusty: Add trusty stats test" 2023-03-21 00:51:30 +00:00
Elliott Hughes
857e29c356 riscv64: fix debuggerd_test build.
This adds the missing assembler for riscv64, even though I don't have a
working tombstoned yet to test it with. There's a distinct possibility
we'll be back to fix the test (because although "register 1" is harmless
for the other architectures, it's the ra register on riscv64; the default
link register), but at least this lets us build the test.

I've also simplified all the assembly to be the simplest sequence I
know that writes 0 to address 0 (because if there was a reason to use
so many instructions before, I want to know what it is so I can write
the missing comment!).

Test: treehugger
Change-Id: I10d117eaedf361d9759a450e0973d07c4f97090e
2023-03-20 17:48:53 -07:00
Daniel Zheng
51a3661421 Merge "Removed hardcoded check to copy AVB Footer" 2023-03-20 23:24:56 +00:00
Elliott Hughes
7e82c0037b riscv64: fix mips-ism.
r29 is the stack pointer on mips, but it's x2 on riscv64 (and the git
history shows that this was indeed copy & pasted from the mips code)
and since bionic always sets up a signal stack with sigaltstack() I
doubt the comment was relevant even on mips (but no-one ever used it,
so who'd know?).

While I'm here, stop using decimal arithmetic --- the whole point was to
have each register contain the value that was obviously appropriate for
that register. (riscv64's mips-like mess of registers all over the place
means that's not going to be super readable, but there's no reason to
make it worse.)

Also, even though I personally prefer the 0xdead from the old mips code,
everyone else is using 0xa5a5, so let's make riscv64 match the others.

Test: treehugger
Change-Id: Ibbae821bc0a02e07164147d621e342224528c2c9
2023-03-20 16:08:15 -07:00
David Anderson
74c7807af1 fastboot: Handle libsparse failures better.
sparse_file_len is not actually infallible; on Windows it's pretty easy
to make it fail by embedding large files in the stream. fastboot didn't
handle this anywhere, leading to bad sparse images when libsparse
runs out of address space.

Bug: 273933042
Bug: 268872725
Test: fastboot flashall on Windows
Change-Id: Ie68aed2f1970e820350d9f97aa89a6c0242229b8
2023-03-20 15:55:57 -07:00
David Anderson
f06debcf24 libsparse: Fix allocation failures on 32-bit systems.
libsparse uses mapped files for length computation checks and writing
output data. The platform-tools package for Windows is 32-bit, and if
an embedded file in the stream is large enough, mapping will fail. In
theory, this failure mode could happen on 64-bit systems as well.

As a workaround, map files in chunks of 256MB instead. This is
implemented by adding a new "fd_chunk" callback to the sparse ops
struct.

Bug: 273933042
Bug: 268872725
Test: fastboot update on Windows
Change-Id: Ic40696b34a1d0951787c899db701fc2fa204eb18
2023-03-20 15:55:57 -07:00