前面玩android4.4 很爽 没有啥问题
最近 android 9,我靠,改动太他妈大了
init原来是c写的,一眼看的明白
现在全部用c++改写,日志还限制输出 太恶心了
说是为了防止日志攻击
对于调试人员来说 没有了日志 等于瞎子
太不爽了!!!
解决方案:
撸代码,最终改内核代码:
static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
{
char *buf, *line;
int level = default_message_loglevel;
int facility = 1; /* LOG_USER */
struct file *file = iocb->ki_filp;
struct devkmsg_user *user = file->private_data;
size_t len = iov_iter_count(from);
ssize_t ret = len;
//printk("in devkmsg_write\n");
if (!user || len > LOG_LINE_MAX){
return -EINVAL;
}
/* Ignore when user logging is disabled. */
if (devkmsg_log & DEVKMSG_LOG_MASK_OFF){
return len;
}
/* Ratelimit when not explicitly enabled. */
if (!(devkmsg_log & DEVKMSG_LOG_MASK_ON)) {
if (!___ratelimit(&user->rs, current->comm)){
//return ret;
}
}
buf = kmalloc(len+1, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
buf[len] = '\0';
if (copy_from_iter(buf, len, from) != len) {
kfree(buf);
return -EFAULT;
}
/*
* Extract and skip the syslog prefix <[0-9]*>. Coming from userspace
* the decimal value represents 32bit, the lower 3 bit are the log
* level, the rest are the log facility.
*
* If no prefix or no userspace facility is specified, we
* enforce LOG_USER, to be able to reliably distinguish
* kernel-generated messages from userspace-injected ones.
*/
line = buf;
if (line[0] == '<') {
char *endp = NULL;
unsigned int u;
u = simple_strtoul(line + 1, &endp, 10);
if (endp && endp[0] == '>') {
level = LOG_LEVEL(u);
if (LOG_FACILITY(u) != 0)
facility = LOG_FACILITY(u);
endp++;
len -= endp - line;
line = endp;
}
}
printk_emit(facility, level, NULL, 0, "%s", line);
kfree(buf);
return ret;
}
加这一句 //return ret; 就完事。哎,落后了,现在android这么牛逼了。。。。。。
还有坑爹的selinux,加个系统的c语言 后台守护进程的服务,折腾了2天
感觉selinux占用了很多系统的资源啊,去掉还不行,就像一个负重前行的人,牵绊太多!!!
博主分享了从Android4.4升级到Android9的体验,指出新版中C++替代C语言编写init,以及日志输出受限带来的调试难题。通过修改内核代码解决了日志限制问题,同时表达了对SELinux复杂性的不满,认为其消耗系统资源。
2009





