KwaiAppTeam / KOOM

KOOM is an OOM killer on mobile platform by Kwai.
Other
3.15k stars 420 forks source link

App进程maps所有者和所属组被修改为root #260

Closed Res2013 closed 9 months ago

Res2013 commented 9 months ago

Koom版本:master分支最新代码 模块:Koom Native Leak模块 真机信息:小米12S和IQOO 10(两个机器系统都是Android13),两个手机均未root 复现步骤:运行Koom源码的koom-demo模块,在首页点击"TEST NATIVE LEAK",跳转到新页面后点击"START NATIVE LEAK MONITOR" 结果:adb shell进入shell环境后,ps查看demo的pid,然后cd /proc/{pid}/,最后ls -al查看maps和smaps等文件的所有者和所属组,结果都是root。 期望:调用LeakMonitor.INSTANCE.start()后,/proc/{pid}/maps文件所有者和所属组是用户级而非root级的。

Res2013 commented 9 months ago

补充一点:修改memory_analyzer.cpp文件中MemoryAnalyzer::CollectUnreachableMem()函数中的代码如下: if (IsValid()) {// This is a test! // ALOGE("MemoryAnalyzer NOT valid"); return std::move(unreachable_mem); } 则没有出现上述问题。

lbtrace commented 9 months ago

补充一点:修改memory_analyzer.cpp文件中MemoryAnalyzer::CollectUnreachableMem()函数中的代码如下: if (IsValid()) {// This is a test! // ALOGE("MemoryAnalyzer NOT valid"); return std::move(unreachable_mem); } 则没有出现上述问题。

感谢反馈问题,你这个修改的意思是注释掉 MemoryAnalyzer::CollectUnreachableMem() 中的 “ ALOGE("MemoryAnalyzer NOT valid");” 就不会出现?

Res2013 commented 9 months ago

补充一点:修改memory_analyzer.cpp文件中MemoryAnalyzer::CollectUnreachableMem()函数中的代码如下: if (IsValid()) {// This is a test! // ALOGE("MemoryAnalyzer NOT valid"); return std::move(unreachable_mem); } 则没有出现上述问题。

感谢反馈问题,你这个修改的意思是注释掉 MemoryAnalyzer::CollectUnreachableMem() 中的 “ ALOGE("MemoryAnalyzer NOT valid");” 就不会出现?

把if (!IsValid())改为if (IsValid())就不会出现

Res2013 commented 9 months ago

查看了文档Linux manual page中的如下描述

The files inside each /proc/pid directory are normally wned by the effective user and effective group ID of the process.However, as a security measure, the ownership is made root:root if the process's "dumpable" attribute is set to a value other than 1.

由于我是Debug包中使用,我把prctl(PR_SET_DUMPABLE, 0, 0, 0, 0);代码给注释掉了,也不存在上述问题。

lbtrace commented 9 months ago

查看了文档Linux manual page中的如下描述 #The files inside each /proc/pid directory are normally wned by the effective user and effective group ID of the process.However, as a security measure, the ownership is made root:root if the process's "dumpable" attribute is set to a value other than 1.

由于我是Debug包中使用,我把prctl(PR_SET_DUMPABLE, 0, 0, 0, 0);代码给注释掉了,也不存在上述问题。

Debug 包(默认 PR_SET_DUMPABLE 1)由于设置 PR_SET_DUMPABLE 为 0,确实改变了 /proc/pid 的 owner and group ID;我周末改成 prctl(PR_SET_DUMPABLE, original, 0, 0, 0) 吧兼容下 debug 包