open/dev/mem即使使用root和SELINUX也会失败
只要显示我的代码open/dev/mem即使使用root和SELINUX也会失败,linux,ubuntu,operating-system,Linux,Ubuntu,Operating System,只要显示我的代码 root@MSI:/tmp# cat main.c #include <stdio.h> #include <fcntl.h> #include <unistd.h> int main() { int fd = open("/dev/mem", O_RDONLY); printf("Result: %d\n", fd); if (fd != -1) { clo
root@MSI:/tmp# cat main.c
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd = open("/dev/mem", O_RDONLY);
printf("Result: %d\n", fd);
if (fd != -1) {
close(fd);
} else {
perror("Failed:");
}
}
root@MSI:/tmp# gcc main.c
root@MSI:/tmp# ./a.out
Result: -1
Failed:: Operation not permitted
root@MSI:/tmp#cat main.c
#包括
#包括
#包括
int main(){
int fd=open(“/dev/mem”,仅限ordu);
printf(“结果:%d\n”,fd);
如果(fd!=-1){
关闭(fd);
}否则{
佩罗尔(“失败:”);
}
}
root@MSI:/tmp#gcc main.c
root@MSI:/tmp#/a.out
结果:-1
失败::不允许操作
Root,没有SELINUX,/dev/mem
具有crw-r-----
权限,但打开失败。
内核版本
5.4.0-49-generic#53 Ubuntu
你想做什么?是否要读取进程的虚拟内存?如果你这么做,考虑使用<代码> /PRO//MEM。你想做什么?是否要读取进程的虚拟内存?如果是,请考虑使用<代码> /PRO//MEM< /代码>。