最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ARM64-QNX : Mprotect give permission denied - Stack Overflow

programmeradmin0浏览0评论

I want to modify the text segment. Using mprotect, I could make the segment writable and update the required data. This is working fine with ARM64-Linux, but on ARM64-QNX, it is giving permission denied.

if (mprotect(page_start_address, page_size, PROT_READ | PROT_WRITE) == -1)
{
       perror("mprotect");
       return 1;
}

We are running an application with the root user. Also, we don't want to use mmap as loading text segment of larger application may not feasible solution.

We had set the required program capabilities, which is not giving any error.

int set_process_abilities()
{
    // Use ThreadCtl to gain debugging privileges
    if (ThreadCtl(_NTO_TCTL_IO, NULL) == -1)
    {
        perror("ThreadCtl IO failed");
        return -1;
    }
    if (ThreadCtl(_NTO_TCTL_HYP_VCPU, NULL) == -1)
    {
        perror("ThreadCtl HYP_VCPU failed");
        return -1;
    }

    // Get all debugging capabilities in a safer way
    int ret = procmgr_ability(0,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_PROT_EXEC,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_MEM_GLOBAL,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_PROT_WRITE_AND_EXEC,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_INTERRUPT,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_PRIORITY,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_IO,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_TRACE,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_MEM_PHYS,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_MEM_PEER,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_CONFSET,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_HYP,
                              PROCMGR_ADN_ROOT | PROCMGR_AOP_ALLOW | PROCMGR_AID_MEM_LOCK,
                              PROCMGR_AID_EOL);

    if (ret < 0)
    {
        perror("Failed to set process abilities");
        return -1;
    }

    printf("Initial program ability ret code %d\n", ret);
    return ret;
}

We have tried to explore the procnto attributes, but this has not resolved the issue either.

pidin arg | grep procnto is:  procnto-smp-instr -mgw -wx -F 70000
发布评论

评论列表(0)

  1. 暂无评论