[高通SM6225][Android13][Kernel5.15]user版本默认获取root权限

news/2024/11/19 0:28:58/

需求描述: 

       user版本默认是不会开启root权限的,但是一般性能版本需要设置CPU GPU DDR performance或者监听节点信息等debug手段去验证当前问题是否与CPU GPU DDR有关系。

基线代码判断逻辑:

1.adb代码会检测相关属性

ro.secure
ro.debuggable (通过调用__android_log_is_debuggable()获取返回值)

2.代码path

2.1 adbd启动时检查属性,决定是否进行权限降级到AID_SHELL
path:system/adb/core/daemon/main.cpp line:121
if (should_drop_privileges()){
… …

2.2 system/adb/core/下搜索__android_log_is_debuggable()

3.修改思路

3.1 should_drop_privileges() 修改强制返回false,保持adb root用户级别
3.2 __android_log_is_debuggable() 返回true
 

packages/modules/adb/daemon/main.cpp
static bool should_drop_privileges() {// The properties that affect `adb root` and `adb unroot` are ro.secure and// ro.debuggable. In this context the names don't make the expected behavior// particularly obvious.//// ro.debuggable://   Allowed to become root, but not necessarily the default. Set to 1 on//   eng and userdebug builds.//// ro.secure://   Drop privileges by default. Set to 1 on userdebug and user builds.bool ro_secure = android::base::GetBoolProperty("ro.secure", true);bool ro_debuggable = __android_log_is_debuggable();// Drop privileges if ro.secure is set...bool drop = ro_secure;std::string build_prop = android::base::GetProperty("ro.build.type", "");bool adb_build_root = (build_prop == "userdebug");if (adb_build_root) {return false;}// ... except "adb root" lets you keep privileges in a debuggable build.std::string prop = android::base::GetProperty("service.adb.root", "");bool adb_root = (prop == "1");bool adb_unroot = (prop == "0");if (ro_debuggable && adb_root) {drop = false;}// ... and "adb unroot" lets you explicitly drop privileges.if (adb_unroot) {drop = true;}return drop;
}

具体实现:

1.关闭ro.secure、ro.adb.secure,打开ro.debuggable
文件路径:qssi/build/make/core/main.mk
详细修改:

diff --git a/core/main.mk b/core/main.mk
index 1579294..f223432 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -365,11 +365,11 @@tags_to_install :=ifneq (,$(user_variant))# Target is secure in user builds.
-  ADDITIONAL_SYSTEM_PROPERTIES += ro.secure=1
+  ADDITIONAL_SYSTEM_PROPERTIES += ro.secure=0ADDITIONAL_SYSTEM_PROPERTIES += security.perf_harden=1ifeq ($(user_variant),user)
-    ADDITIONAL_SYSTEM_PROPERTIES += ro.adb.secure=1
+    ADDITIONAL_SYSTEM_PROPERTIES += ro.adb.secure=0endififeq ($(user_variant),userdebug)
@@ -377,7 +377,7 @@tags_to_install += debugelse# Disable debugging in plain user builds.
-    enable_target_debugging :=
+    enable_target_debugging := trueendif# Disallow mock locations by default for user builds
@@ -399,7 +399,7 @@ADDITIONAL_SYSTEM_PROPERTIES += dalvik.vm.lockprof.threshold=500else # !enable_target_debugging# Target is less debuggable and adbd is off by default
-  ADDITIONAL_SYSTEM_PROPERTIES += ro.debuggable=0
+  ADDITIONAL_SYSTEM_PROPERTIES += ro.debuggable=1endif # !enable_target_debugging## eng ##

2.should_drop_privileges return false,allow adb root
文件路径:qssi/packages/modules/adb/daemon/main.cpp
详细修改:

diff --git a/daemon/main.cpp b/daemon/main.cpp
index 1d4e626..6c9792f 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -74,6 +74,7 @@//// ro.secure://   Drop privileges by default. Set to 1 on userdebug and user builds.
+    return false;bool ro_secure = android::base::GetBoolProperty("ro.secure", true);bool ro_debuggable = __android_log_is_debuggable();

3.ALLOW_ADBD_DISABLE_VERITY=1
文件路径:qssi/system/core/fs_mgr/Android.bp
详细修改:

diff --git a/fs_mgr/Android.bp b/fs_mgr/Android.bp
index 49761ac..ac1c31d 100644
--- a/fs_mgr/Android.bp
+++ b/fs_mgr/Android.bp
@@ -109,7 +109,8 @@"libfstab",],cppflags: [
-        "-DALLOW_ADBD_DISABLE_VERITY=0",
+        "-UALLOW_ADBD_DISABLE_VERITY",
+        "-DALLOW_ADBD_DISABLE_VERITY=1",],product_variables: {debuggable: {
@@ -237,7 +238,8 @@"fs_mgr_remount.cpp",],cppflags: [
-        "-DALLOW_ADBD_DISABLE_VERITY=0",
+        "-UALLOW_ADBD_DISABLE_VERITY",
+        "-DALLOW_ADBD_DISABLE_VERITY=1",],product_variables: {debuggable: {

4.close selinux    enforce=Permissive
文件路径:qssi/system/core/init/selinux.cpp
详细修改:

diff --git a/init/selinux.cpp b/init/selinux.cpp
index 6ae4bc0..4d50cb6 100644
--- a/init/selinux.cpp
+++ b/init/selinux.cpp
@@ -124,6 +124,7 @@bool IsEnforcing() {// close selinux for user version with root
+    return false;#if defined(LCT_BUILD_TYPE_FACTORY)return false;#endif

5.sepolicy
文件路径:qssi/system/sepolicy/Android.mk
详细修改:

diff --git a/Android.mk b/Android.mk
index a2793af..da5cebf 100644
--- a/Android.mk
+++ b/Android.mk
@@ -613,7 +613,7 @@ifneq ($(filter address,$(SANITIZE_TARGET)),)local_fc_files += $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))endif
-ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+ifneq (,$(filter user userdebug eng,$(TARGET_BUILD_VARIANT)))local_fc_files += $(wildcard $(addsuffix /file_contexts_overlayfs, $(PLAT_PRIVATE_POLICY)))endif


http://www.ppmy.cn/news/1000065.html

相关文章

【vue】 vue2 监听滚动条滚动事件

代码 直接上代码&#xff0c;vue单文件 index.vue <template><div class"content" scroll"onScroll"><p>内容</p><p>内容</p><p>内容</p><p>内容</p><p>内容</p><p>内容…

YAPI接口自动鉴权功能部署详解

目录 安装准备 在线安装 离线安装 配置使用 安装准备 以下操作&#xff0c;默认要求自己部署过yapi&#xff0c;最好是部署过yapi二次开发环境。 无论是选择在线安装或者是本地安装&#xff0c;都需要安装client工具。 1、yapi-cli&#xff1a;npm install yapi-cli –g…

系统架构设计师_备考第2天(计算机组成与体系结构)

文章目录 考频&#xff08;3分左右&#xff09;一、计算机结构二、CPU组成三、冯诺依曼结构和哈弗结构四、层次化存储结构五、Cache 考频&#xff08;3分左右&#xff09; 提示&#xff1a;这里可以添加本文要记录的大概内容&#xff1a; 计算机结构&#xff08;★&#xff0…

数字图像处理-彩色图像处理

文章目录 一、彩色模型1.1RGB彩色模型1.2CMY和CMYK彩色模型1.3HSI彩色模型 二、伪彩色图像处理2.1灰度分层2.2灰度到彩色的变换 三、彩色图像的分割3.1RGB中的彩色图像分割3.2彩色边缘检测 一、彩色模型 1.1RGB彩色模型 RGB空间是生活中最常用的一个模型&#xff0c;电视机、…

企业即时通讯软件为何成为企业内部沟通的主流工具?

近年来&#xff0c;随着数字化程度不断提升&#xff0c;企业内部沟通方式也发生了诸多变化。传统的电子邮件已经逐渐被企业即时通讯软件代替&#xff0c;成为了企业内部沟通的主流工具。在这些软件中&#xff0c;J2L3x是其中独具特色的一个。本文将从以下几个方面来讲解企业即时…

超导电性的基本现象和相关理论

超导体 Hg 超导电性的基本现象和相关理论 超导体的基本特性 低温零电阻突变&#xff08;< 10^{-23 \Omega/m}&#xff09; 良导体在 10^{-10} \Omega/m临界温度迈斯纳效应 完全排磁通效应&#xff08;完全抗磁性&#xff09; 超导体物体内部不存在电场 第一类超导体与第二类…

React从入门到实战-react脚手架,消息订阅与发布

创建项目并启动 全局安装 npm install -g create-react-app切换到想创建项目的目录&#xff0c;使用命令&#xff1a;create-react-app 项目名称 ​ [外链图片转存失败,源站可能有防盗链机制,建议将图片保存中…(iQ6hEUgAABpQAAAD1CAYAAABeIRZoAAAAAXNSR0IArs4c6QAAIABJREFUe…

Prometheus服务器、Prometheus被监控端、Grafana、Prometheus服务器、Prometheus被监控端、Grafana

day03 day03Prometheus概述部署Prometheus服务器环境说明&#xff1a;配置时间安装Prometheus服务器添加被监控端部署通用的监控exporterGrafana概述部署Grafana展示node1的监控信息监控MySQL数据库配置MySQL配置mysql exporter配置mysql exporter配置prometheus监控mysql自动…