Reputation: 23
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
Upvotes: 0
Views: 18