天天看點

Android 出現 avc: denied { execmod }如何處理?

内置應用會出現各種問題,不過内置應用會出現avc報錯到還是第一次,報錯如下:

11-21 11:20:18.427  6603  6603 W tudent.activity: type=1400 audit(0.0:51): avc: denied { execmod } for path="/system/app/education_student/lib/arm/libhpHandPends.so" dev="mmcblk0p24" ino=424 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:system_file:s0 tclass=file permissive=0
11-21 11:20:18.437  6603  6603 W linker  : /system/app/education_student/lib/arm/libhpHandPends.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
           

其他的so檔案都沒有錯誤,隻有這個so出現錯誤,而且手動安裝也不會出現問題,下面隻好修改te檔案來解決這個問題了

denied後面{}裡的是要執行的動作,比如append,open,execmod,link等等

scontext指的是域,對應的是te檔案 上面報錯這條對應te檔案是untrusted_app.te,scontext全寫是source_type context;

tcontext指的是目标類型,上面報錯這條對應的是目标類型system_file,tcontext全寫是target_type context;

tclass指的是類别,上面報錯這條對應的是類别是file,

te表達式格式:

rule_name:規則名稱,除了有allow還有dontaudit,auditallow和neverallow

source_type:源類型,對應一個很重要的概念--------域(domain)

tartget_type:目标的類型,即安全上下文,SELinux一個重要的判斷對象

class:類别,目标(客體)是哪種類别,主要有File,Dir,Socket,SEAndroid還有Binder等,在這些基礎上又細分出裝置字元類型(chr_file),連結檔案(lnk_file)等。可以通過ls -l檢視檔案類型

perm_set:動作集

下面在selinux中添加上這條,找到untrusted_app.te檔案,路徑是system/core/rootdir/untrusted_app.te,然後加上

allow untrusted_app system_file:file execmod;
           

然後隻需要編譯boot.img就可以了~