【GTS-Fail】GtsSecurityHostTestCases#testNoExemptionsForSocketsBetweenCoreAndVendorBan
[GTS]GtsSecurityHostTestCases#testNoExemptionsForSocketsBetweenCoreAndVendorBan
【问题描述】
Gts-7.0-r4工具报出失败项
GtsSecurityHostTestCases
com.google.android.security.gts.SELinuxHostTest#testNoExemptionsForSocketsBetweenCoreAndVendorBan
<Failure message="junit.framework.AssertionFailedError: Policy exempts domains from ban on socket communications between core and vendor: [hal_audio_default]">
<StackTrace>junit.framework.AssertionFailedError: Policy exempts domains from ban on socket communications between core and vendor: [hal_audio_default]
at junit.framework.Assert.fail(Assert.java:57)
at junit.framework.TestCase.fail(TestCase.java:227)
at com.google.android.security.gts.SELinuxHostTest.testNoExemptionsForSocketsBetweenCoreAndVendorBan(SELinuxHostTest.java:221)
这里有个坑,报问题的时候说上个版本有,其实最终查证0004版本(2.20前)就有这个失败项了,当时芯片厂商也告知是waiver项了。。。
【问题结论】
是waiver项
失败项是由google的auto-patch代码导致,如果第一次遇到可以咨询aml是否waiver。
AuthBlog:秋城https://www.cnblogs.com/houser0323
【分析详细】
测试逻辑总览
使用linux可执行程序:sepolicy-analyze,对机顶盒中的/sys/fs/selinux/policy文件进行解析,要求不能有返回值,命令是:
sepolicy-analyze policy attribute socket_between_core_and_vendor_violators
即:不允许有type(类型)与该attribute(属性)“socket_between_core_and_vendor_violators”有关联,字面意思:core与vendor的违规socket特权
system/sepolicy/tools/sepolicy-analyze/README
ATTRIBUTE (attribute)
sepolicy-analyze out/target/product//root/sepolicy attribute
Displays the types associated with the specified attribute name.
该权限详细限制在以下代码中有论述,Android TREBLE架构解耦计划相关
system/sepolicy/prebuilts/api/26.0/public/domain.te
system/sepolicy/prebuilts/api/27.0/public/domain.te
system/sepolicy/prebuilts/api/28.0/public/domain.te:
system/sepolicy/public/domain.te
# On full TREBLE devices, socket communications between core components and vendor components are
# not permitted.
full_treble_only(`
# Most general rules first, more specific rules below.
# Core domains are not permitted to initiate communications to vendor domain sockets.
# We are not restricting the use of already established sockets because it is fine for a process
# to obtain an already established socket via some public/official/stable API and then exchange
# data with its peer over that socket. The wire format in this scenario is dicatated by the API
# and thus does not break the core-vendor separation.
梳理测试项逻辑
反编译后定位测试项
./com/google/android/security/gts/SELinuxHostTest.java
public void testNoExemptionsForVendorExecutingCore() throws Exception {
if (isFullTrebleDevice()) {
Set<String> types = sepolicyAnalyzeGetTypesAssociatedWithAttribute("vendor_executes_system_violators");//该语句是测试判断,返回测试结果
if (!types.isEmpty()) {
List<String> sortedTypes = new ArrayList(types);
Collections.sort(sortedTypes);
fail("Policy exempts vendor domains from ban on executing files in /system: " + sortedTypes);//此处assert,原因是容器types有东西,东西就是‘[hal_audio_default]’
}
}
}
看一下方法的测试逻辑:sepolicyAnalyzeGetTypesAssociatedWithAttribute()
通过ProcessBuilder开启一个进程,用于执行linux命令:sepolicy-analyze policy attribute socket_between_core_and_vendor_violators
然后获取这个命令的标准输出进行结果判断
private Set<String> sepolicyAnalyzeGetTypesAssociatedWithAttribute(String attribute) throws Exception {
BufferedReader in;
Throwable th;
Throwable th2;
Set<String> types = new HashSet();
//通过ProcessBuilder开启一个进程,用于执行linux命令:sepolicy-analyze policy attribute socket_between_core_and_vendor_violators
ProcessBuilder pb = new ProcessBuilder(new String[]{this.mSepolicyAnalyze.getAbsolutePath(), this.mDevicePolicyFile.getAbsolutePath(), "attribute", attribute});
......
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
th = null;
while (true) {
try {
String type = in.readLine();
if (type != null) {
types.add(type.trim());//获取有效标准输出,写到结果容器中存储
}}}
......
return types;
......
}
现在基本逻辑就清楚了,只要这个命令执行有结果返回就是不被允许的,现在需要分析这个工具‘sepolicy-analyze’是干嘛的?
在Android工程源码中搜索,我们找到了这个host可执行程序的源码
system/sepolicy/tools/sepolicy-analyze/
结合网络资料以及阅读源码和README文档,澄清测试的命令用途:解析policy文件返回与attribute相关联的type值
system/sepolicy/tools/sepolicy-analyze/README
63 ATTRIBUTE (attribute)
64 sepolicy-analyze out/target/product//root/sepolicy attribute
65
66 Displays the types associated with the specified attribute name.
工程中搜索确认
搜索确认到底在哪里使得他们关联的,定位到文件
./system/sepolicy/vendor/hal_audio_default.te:1
type hal_audio_default, domain, socket_between_core_and_vendor_violators;
查证git log,我们发现是如下的commit导致的,是google的auto-path
commit 783f5b52195f0168f4c9db29b5a80ac63fb04020
Author: xxxxxx
Date: Mon Feb 17 11:33:16 2020 +0800
auto patch added:CecAudio
diff --git a/vendor/hal_audio_default.te b/vendor/hal_audio_default.te
index 0dc2170..9da0f1b 100644
--- a/vendor/hal_audio_default.te
+++ b/vendor/hal_audio_default.te
@@ -1,4 +1,4 @@
-type hal_audio_default, domain;
+type hal_audio_default, domain, socket_between_core_and_vendor_violators; #此处添加的关联,问题找到了根源
hal_server_domain(hal_audio_default, hal_audio)
到此,问题很大概率可确认为Google-waiver,因为引入问题的代码是Google的。接下来需向芯片厂商或Google沟通确认
由于报问题的乌龙,事实是该问题很久之前已澄清过,所以这一通分析并木有什么卵用。。。。。。
【GTS-Fail】GtsSecurityHostTestCases#testNoExemptionsForSocketsBetweenCoreAndVendorBan的更多相关文章
- 【GTS】关于GtsTetheringTestCases模块的几个失败项
GTS---关于GtsTetheringTestCases模块的几个失败项 1.run gts -m GtsTetheringTestCases -t com.google.android.tethe ...
- 如何结合自己本地数据库,使用【百度地图】API
如何结合自己本地数据库,使用[百度地图]API百度地图使用越来越多,官网上的示例数据都是写死的,实际上我们的开发中的数据都是从数据库中取出来的,最近看了很多大神的文章,结合自己本地数据库使用百度地图A ...
- 【MVC 4】4.MVC 基本工具(Visual Studio 的单元测试、使用Moq)
作者:[美]Adam Freeman 来源:<精通ASP.NET MVC 4> 3.Visual Studio 的单元测试 有很多.NET单元测试包,其中很多是开源和免费的.本 ...
- 【UER #1】[UOJ#12]猜数 [UOJ#13]跳蚤OS [UOJ#14]DZY Loves Graph
[UOJ#12][UER #1]猜数 试题描述 这一天,小Y.小D.小C正在愉快地玩耍. 小Y是个数学家,他一拍脑袋冒出了一个神奇的完全平方数 n. 小D是个机灵鬼,很快从小Y嘴里套出了 n的值.然后 ...
- 【C/C++】Linux下system()函数引发的错误
http://my.oschina.net/renhc/blog/54582 [C/C++]Linux下system()函数引发的错误 恋恋美食 恋恋美食 发布时间: 2012/04/21 11:3 ...
- 【zabbix系列】安装与加入host
測试环境 Ubuntu 14.04.1 LTS [服务端安装] 关于安装官方提供了非常具体的安装方法,包含各平台的源代码及包安装.关于其它版本号Linux请參考 https://www.zabbix. ...
- 微信【跳一跳】 opencv视觉识别 + 物理外挂
视频连接:http://v.youku.com/v_show/id_XMzMyNDQxNTA0OA==.html?spm=a2h3j.8428770.3416059.1 初入门C++ 与 opencv ...
- 【English Teradata】名称缩写
日常缩写 [GTM]Teradata Go-to-Market employees [GTS]Teradata Global Technical Support [GSC] [CS&S]Cus ...
- 【运维】浪潮服务器一块硬盘显示红色Offline(或者Failed)解决办法
[写在前面] 最近服务器不知道为什么总是出现故障,以前戴尔服务器硬盘出现故障,也就是说硬盘旁边的灯显示为红色的时候,一般情况下都是表示硬盘坏掉了,直接买一块新的硬盘,将坏掉的硬盘拿 ...
随机推荐
- iOS数据锁
简介 当一个线程访问数据时,而其他数据不能进行访问,保证线程安全或者可以理解为执行多线程,对于共享资源访问时保证互斥的要求 文章 不再安全的 OSSpinLock iOS开发中的11种锁以及性能对比 ...
- orcale 11g安装,创建表空间,用户,授权用户
一.卸载旧oracle 用Oracle自带的卸载程序不能从根本上卸载Oracle,从而为下次的安装留下隐患,那么怎么才能完全卸载Oracle呢?那就是直接注册表清除,步骤如下: 1. 开始->设 ...
- awk使用和详解
awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分再进行各 ...
- 2015-09-14-初级string
标准库string类型 string对象初始化 string s1; string s2(s1); string s3("value"); string s4(n,'c'); st ...
- MariaDB 外键
drop database literatureDB; create database literatureDB; use literatureDB; # 类型表 create table `type ...
- Nginx笔记总结五:Nginx配置虚拟主机
upstream proxy1 { server ; } upstream proxy2 { server ; } server { listen ; server_name www1.dlab.co ...
- 深度学习之TensorFlow安装与初体验
深度学习之TensorFlow安装与初体验 学习前 搞懂一些关系和概念 首先,搞清楚一个关系:深度学习的前身是人工神经网络,深度学习只是人工智能的一种,深层次的神经网络结构就是深度学习的模型,浅层次的 ...
- charles添加https支持
- Leetcode 20题 有效的括号(Valid Parentheses) Java语言求解
题目描述: 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效. 有效字符串需满足: 左括号必须用相同类型的右括号闭合. 左括号必须以正确的顺序闭合. 注意空 ...
- Git pull 卡在Unpacking objects
今天在拉取远程仓库的时候在Unpacking objects阶段 进度条卡住,不知道什么原因. 翻取相关资料搜索后得知:在拉取大型二进制对象(如Adobe Illustrator文件等)可能会使整个拉 ...