Skip to content

Commit

Permalink
feat: sync with latest sources of TrebleDroid
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 20, 2024
1 parent 9ef5ebc commit f8478b6
Show file tree
Hide file tree
Showing 33 changed files with 442 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 04d510d50fab21cb274ba00d3be785c5122277bc Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Wed, 23 Feb 2022 17:37:47 -0500
Subject: [PATCH 01/26] Let system override ro.apex.updatable
Subject: [PATCH 01/27] Let system override ro.apex.updatable

APEX are broken because of a kernel bug in Android 10 devices
So we have system set ro.apex.updatable = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 7d97f7b2b89cce84d88aa386ee787bd3b43cec43 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Sun, 18 Oct 2020 18:14:47 +0200
Subject: [PATCH 02/26] Don't abandon creating property tree if there is a
Subject: [PATCH 02/27] Don't abandon creating property tree if there is a
conflict, and hope for the best

Change-Id: I194c815fdd58bfb84aaf7db02b8f0d00b4db21e8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 1c9259a7e41e4e4b425673bd9ddc1e2669c05571 Mon Sep 17 00:00:00 2001
From: Isaac Chen <[email protected]>
Date: Wed, 23 Jun 2021 13:07:30 +0800
Subject: [PATCH 03/26] init: Do not start console service when debuggable
Subject: [PATCH 03/27] init: Do not start console service when debuggable

Google added a check for this in R, when it's running it will show a
notification about that performance is impacted.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 587225dc48719b3b9e1d1327fd87445f3166de1e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Wed, 4 Sep 2019 21:11:48 +0200
Subject: [PATCH 04/26] Panic into recovery rather than bootloader
Subject: [PATCH 04/27] Panic into recovery rather than bootloader

Getting last_kmsg/pstore from bootloader isn't possible for other people
than the OEM, but we have TWRP to access last_kmsg/pstore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From ceb8ab56714c59a54305b077434cd542d236a2f3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Tue, 14 Aug 2018 19:33:03 +0200
Subject: [PATCH 05/26] Detect allowed sdcard options based on vndk
Subject: [PATCH 05/27] Detect allowed sdcard options based on vndk

Some kernel crashes when using too recent sdcardfs options

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From bd9ac352d7cbc086217ef4514197563152c9267b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Fri, 1 Nov 2019 18:22:13 +0100
Subject: [PATCH 06/26] Ugly but secure: Set /dev/uinput as 0666 to fix
Subject: [PATCH 06/27] Ugly but secure: Set /dev/uinput as 0666 to fix
fingerprint sensor on some devices

cf https://github.com/phhusson/device_phh_treble/pull/122/commits/e000d69c286b6686777ea6f1867f379e30273e48
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 8f69dfddeea5910dff831edb848e94895aeae58a Mon Sep 17 00:00:00 2001
From: Alberto Ponces <[email protected]>
Date: Tue, 1 Feb 2022 13:48:35 +0000
Subject: [PATCH 07/26] Revert "Set /system/xbin permissions to 750."
Subject: [PATCH 07/27] Revert "Set /system/xbin permissions to 750."

This reverts commit 42a1a126e554a8bca31d0afc832848b7b0fa1f4e.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 1c441f20e514ea4e9aef174fad2f07fe7687e128 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Sat, 22 Jan 2022 14:34:45 -0500
Subject: [PATCH 08/26] Add my own OTA mechanism going over /data
Subject: [PATCH 08/27] Add my own OTA mechanism going over /data

Change-Id: I9cacff2d761affa0376b4bb8ca63353a9d95b5de
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From c3504e11543607990e44c296eed4a10a071a1da2 Mon Sep 17 00:00:00 2001
From: Alberto Ponces <[email protected]>
Date: Mon, 3 Oct 2022 13:50:36 +0100
Subject: [PATCH 09/26] fs_mgr: Keep allowing encryptable fstab flag
Subject: [PATCH 09/27] fs_mgr: Keep allowing encryptable fstab flag

Some users still use "encryptable" flag while being unencrypted. Let them still boot their devices.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From f07969766294cc363519a053ed11b0e243d754ab Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Thu, 10 Nov 2022 13:30:50 -0500
Subject: [PATCH 10/26] FDE is dead. Fallback FDE to no encryption, and FDE+FBE
Subject: [PATCH 10/27] FDE is dead. Fallback FDE to no encryption, and FDE+FBE
to FBE

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From ffdfd4b49e0b51d700cc7a32ad5e9427ea12f962 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Fri, 9 Dec 2022 13:57:10 -0500
Subject: [PATCH 11/26] Let system override adb/secure props, so we dont get
Subject: [PATCH 11/27] Let system override adb/secure props, so we dont get
stuck in ro.adb.secure=1 vendors

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 7e8cc69d9c74e90c4a3f02e7b2ded007b038416d Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Fri, 28 Apr 2023 12:29:05 -0400
Subject: [PATCH 12/26] Allow apex on > 5.0 kernels. This is needed because on
Subject: [PATCH 12/27] Allow apex on > 5.0 kernels. This is needed because on
Pixels, camera HAL are exclusively in vendor apex

Change-Id: I334cde4c5557b0ff70d550205c5bb727d4b5dbf5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From cb7881381bbd843508e94d68fb4ec46c78ffb110 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Sat, 27 May 2023 05:36:21 -0400
Subject: [PATCH 13/26] watchdogd: Support pinging two watchdogs
Subject: [PATCH 13/27] watchdogd: Support pinging two watchdogs

---
watchdogd/watchdogd.cpp | 33 +++++++++++++++++++++++++++++++++
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 4840ea349bb1e28a17c9946a7936aba02b9124fe Mon Sep 17 00:00:00 2001
From: Raphael Mounier <[email protected]>
Date: Sun, 21 May 2023 16:15:42 +0200
Subject: [PATCH 14/26] healthd : offline charger fix screen off 3/3
Subject: [PATCH 14/27] healthd : offline charger fix screen off 3/3

When the phone is charging, the animation never turns off on huawei phones (kernel 4.9). This patch allows you to turn it off by setting the brightness to 0. This problem may also exist on other phone models.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From b839afac5a5c9bc33628d88f939f2fc5687b158e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Tue, 6 Jun 2023 16:17:11 +0100
Subject: [PATCH 15/26] Disable quotas on legacy devices with encryption
Subject: [PATCH 15/27] Disable quotas on legacy devices with encryption
disabled

Source: https://t.me/phhtreblebuilders/20521 and https://t.me/phhtreblebuilders/20546
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 2891daccac6415cd279c3ff4d79feacc931a66d4 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Tue, 11 Jul 2023 14:52:40 -0400
Subject: [PATCH 16/26] Add /vendor/firmware_mnt. Moto Razr 2019 look for
Subject: [PATCH 16/27] Add /vendor/firmware_mnt. Moto Razr 2019 look for
firmwares (modem, sensors, ...) there

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 049c67eeba4f595d45a525a00215c44530b42540 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Fri, 6 Oct 2023 08:20:48 -0400
Subject: [PATCH 17/26] Ignore dm-verity setup issues
Subject: [PATCH 17/27] Ignore dm-verity setup issues

On Amlogic STB Android 9 vendor, no boot device is setup
(fstab doesn't use /dev/block/by-name but more direct mappings)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 6258ea72563efa5c199c02ef9604547153f93b19 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Wed, 26 Oct 2022 17:59:11 -0400
Subject: [PATCH 18/26] Fix support for devices without cgroupv2 support
Subject: [PATCH 18/27] Fix support for devices without cgroupv2 support

This is technically a revert of 1bd1746447.
The warning inside the commit doesn't really apply to us, because the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0f46ac7b95f776d33f03805d6c910932ee058c73 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Fri, 6 Oct 2023 19:01:27 -0400
Subject: [PATCH 19/26] Disable project_quota on old devices but new enough to
Subject: [PATCH 19/27] Disable project_quota on old devices but new enough to
have encryption (they do keep quota support)

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From c032fa6bf86acbd008e78cb16f3d9f5a5329a71e Mon Sep 17 00:00:00 2001
From: Huy Hoang <[email protected]>
Date: Thu, 19 Oct 2023 07:06:55 +0700
Subject: [PATCH 20/26] fix: Nubia 6 series custom rc action prop validation
Subject: [PATCH 20/27] fix: Nubia 6 series custom rc action prop validation

---
init/action_parser.cpp | 1 +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 5234783240fd4bd830d4c8d7d8dd736dc18fbc73 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Thu, 23 Nov 2023 11:05:20 -0500
Subject: [PATCH 21/26] HACK: Ignore errors when setting fscrypt directory.
Subject: [PATCH 21/27] HACK: Ignore errors when setting fscrypt directory.
Some devices fail to set it on first boot, but is happy later (?!?)

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 085947955ecfc02462913aa8093c95909b3096b5 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Sat, 25 Nov 2023 09:51:14 -0500
Subject: [PATCH 22/26] Keep our own version of ro.logd.kernel. We do want
Subject: [PATCH 22/27] Keep our own version of ro.logd.kernel. We do want
logcat -b kernel, unlike what OEM set from their vendor

---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 5f15a6cb9f69eeb5f51605a904a7aa5f80c676da Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Tue, 16 Jan 2024 10:30:57 -0500
Subject: [PATCH 23/26] Keep capex when there are vendor apexes
Subject: [PATCH 23/27] Keep capex when there are vendor apexes

When disabling APEX on Linux < 5, we might break some vendor APEXes
For instance Pixel 4a on Linux 4.14.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 739b1793ff18c7141e89d75746cd672091ac920c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Thu, 25 Jan 2024 15:20:10 -0500
Subject: [PATCH 24/26] When setting ro.apex.updatable, actually set the value
Subject: [PATCH 24/27] When setting ro.apex.updatable, actually set the value

Before this change, we were only changing the override, but on newest
Android 14 vendor, they don't explicitly set ro.apex.updatable=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 94ee2a807995e98b1f96441928e27db91a6d4843 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Sun, 31 Mar 2024 17:18:05 -0400
Subject: [PATCH 25/26] If AVB fails, ignore/disable AVB
Subject: [PATCH 25/27] If AVB fails, ignore/disable AVB

DO NOT INCLUDE THIS PATCH If you want to run GSIs on a locked bootloader

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From cb11a40f7fccba44d03101b900aa4ba658e2bdf3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Tue, 2 Apr 2024 16:53:08 -0400
Subject: [PATCH 26/26] Flattened apexes no longer exist, we'll deal with it
Subject: [PATCH 26/27] Flattened apexes no longer exist, we'll deal with it
another way

---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
From 2166c5b3c22738cec0f838c69229cc7d7c8a3363 Mon Sep 17 00:00:00 2001
From: Alberto Ponces <[email protected]>
Date: Sun, 20 Oct 2024 21:15:08 +0100
Subject: [PATCH 27/27] Revert "init: remove session keyring workaround for old
kernels"

This reverts commit 5d7c35ce205f1b4afadd6a1725c0b5e03962a97c.
---
init/Android.bp | 1 +
init/builtins.cpp | 3 +++
init/fscrypt_init_extensions.cpp | 16 ++++++++++++++++
init/fscrypt_init_extensions.h | 1 +
init/fuzzer/Android.bp | 1 +
init/init.cpp | 6 ++++++
6 files changed, 28 insertions(+)

diff --git a/init/Android.bp b/init/Android.bp
index 57e5a681a..bad33d94f 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -191,6 +191,7 @@ libinit_cc_defaults {
"libfs_mgr",
"libgsi",
"libhidl-gen-utils",
+ "libkeyutils",
"liblog",
"liblogwrap",
"liblp",
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 3be6c7cb9..7558f4dff 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -596,6 +596,9 @@ static Result<void> queue_fs_event(int code) {
} else if (code == FS_MGR_MNTALL_DEV_FILE_ENCRYPTED ||
code == FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED ||
code == FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION) {
+ if (!FscryptInstallKeyring()) {
+ return Error() << "FscryptInstallKeyring() failed";
+ }
SetProperty("ro.crypto.state", "encrypted");

// Although encrypted, vold has already set the device up, so we do not need to
diff --git a/init/fscrypt_init_extensions.cpp b/init/fscrypt_init_extensions.cpp
index 6a561e54c..fbd818957 100644
--- a/init/fscrypt_init_extensions.cpp
+++ b/init/fscrypt_init_extensions.cpp
@@ -34,12 +34,28 @@
#include <cutils/properties.h>
#include <cutils/sockets.h>
#include <fscrypt/fscrypt.h>
+#include <keyutils.h>
#include <logwrap/logwrap.h>

#define TAG "fscrypt"

using namespace android::fscrypt;

+bool FscryptInstallKeyring() {
+ if (keyctl_search(KEY_SPEC_SESSION_KEYRING, "keyring", "fscrypt", 0) != -1) {
+ LOG(INFO) << "Keyring is already created";
+ return true;
+ }
+ key_serial_t device_keyring = add_key("keyring", "fscrypt", 0, 0, KEY_SPEC_SESSION_KEYRING);
+
+ if (device_keyring == -1) {
+ PLOG(ERROR) << "Failed to create keyring";
+ return false;
+ }
+ LOG(INFO) << "Keyring created with id " << device_keyring << " in process " << getpid();
+ return true;
+}
+
// TODO(b/139378601): use a single central implementation of this.
static void delete_dir_contents(const std::string& dir) {
char* const paths[2] = {const_cast<char*>(dir.c_str()), nullptr};
diff --git a/init/fscrypt_init_extensions.h b/init/fscrypt_init_extensions.h
index 5e0269a3b..d357bb2fd 100644
--- a/init/fscrypt_init_extensions.h
+++ b/init/fscrypt_init_extensions.h
@@ -25,5 +25,6 @@ enum class FscryptAction {
kDeleteIfNecessary,
};

+bool FscryptInstallKeyring();
bool FscryptSetDirectoryPolicy(const std::string& ref_basename, FscryptAction action,
const std::string& dir);
diff --git a/init/fuzzer/Android.bp b/init/fuzzer/Android.bp
index 5823932d2..65d280335 100644
--- a/init/fuzzer/Android.bp
+++ b/init/fuzzer/Android.bp
@@ -31,6 +31,7 @@ cc_defaults {
"libbase",
"libfs_mgr",
"libhidl-gen-utils",
+ "libkeyutils",
"liblog",
"libprocessgroup",
"libselinux",
diff --git a/init/init.cpp b/init/init.cpp
index 19e909fcb..aeccd6696 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -54,6 +54,7 @@
#include <android-base/thread_annotations.h>
#include <fs_avb/fs_avb.h>
#include <fs_mgr_vendor_overlay.h>
+#include <keyutils.h>
#include <libavb/libavb.h>
#include <libgsi/libgsi.h>
#include <libsnapshot/snapshot.h>
@@ -970,6 +971,11 @@ int SecondStageMain(int argc, char** argv) {
<< " to /proc/1/oom_score_adj: " << result.error();
}

+ // Set up a session keyring that all processes will have access to. It
+ // will hold things like FBE encryption keys. No process should override
+ // its session keyring.
+ keyctl_get_keyring_ID(KEY_SPEC_SESSION_KEYRING, 1);
+
// Indicate that booting is in progress to background fw loaders, etc.
close(open("/dev/.booting", O_WRONLY | O_CREAT | O_CLOEXEC, 0000));

--
2.34.1

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 6f200e13b6568e383dc4299cac1b9a379978bb51 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Sat, 17 Feb 2018 19:39:38 +0100
Subject: [PATCH 1/5] Allow deletion of symlink
Subject: [PATCH 1/6] Allow deletion of symlink

Change-Id: I9731895f88729072297f753088583aabbe6990f4
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3f3d74d784836155f1f34ddbebea792dcd32d75d Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Sat, 7 Mar 2020 14:49:09 +0100
Subject: [PATCH 2/5] Failing to create facedata shouldn't be fatal
Subject: [PATCH 2/6] Failing to create facedata shouldn't be fatal

Some Pie vendors create it on their own, so SELinux would deny that
Also not all devices have face unlock anyway
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 63c86aab356c14412f1ac5a6b543ba6634e35aea Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Mon, 29 Nov 2021 17:49:13 -0500
Subject: [PATCH 3/5] Don't unmount rw-system.sh binds
Subject: [PATCH 3/6] Don't unmount rw-system.sh binds

Change-Id: If9132c21defa8b09879b79a70794c5275d6852d0
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 14520a341145026b6ad5b6111a4ee80174708b2d Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <[email protected]>
Date: Tue, 18 Oct 2022 16:08:09 -0400
Subject: [PATCH 4/5] Exfat can be mounted with "exfat" kernel fs driver, or
Subject: [PATCH 4/6] Exfat can be mounted with "exfat" kernel fs driver, or
"sdfat" or "texfat" (Samsung and Sony variants)

---
Expand Down
Loading

0 comments on commit f8478b6

Please sign in to comment.