Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
open/dev/mem即使使用root和SELINUX也会失败_Linux_Ubuntu_Operating System - Fatal编程技术网

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< /代码>。