android 日志系统 xxx output lines suppressed due to ratelimiting

博主分享了从Android4.4升级到Android9的体验,指出新版中C++替代C语言编写init,以及日志输出受限带来的调试难题。通过修改内核代码解决了日志限制问题,同时表达了对SELinux复杂性的不满,认为其消耗系统资源。

前面玩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占用了很多系统的资源啊,去掉还不行,就像一个负重前行的人,牵绊太多!!!

 

 

 

评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值