Monday, September 11, 2017

Open /dev/mem file failed when running as a root priviledge

Hi all,

Greetings from me!

I want to run dmidecode (https://github.com/mirror/dmidecode) on OpenBSD
6.1, but executing it will report following errors:

# ./dmidecode
# dmidecode 3.1
Scanning /dev/mem for entry point.
/dev/mem: Operation not permitted

After single-step debugging, I find the error is from open /dev/mem:

if ((fd = open(filename, O_RDONLY)) == -1)
{
if (errno != ENOENT)
perror(filename);
return NULL;
}

I execute program as a root, and the attributes of `/dev/mem`:

# ls -lt /dev/mem
crw-r----- 1 root kmem 2, 0 Aug 25 18:38 /dev/mem

So it should open successfully. Could anyone give some clues of this issue?

Thanks very much in advance!

Best Regards
Nan Xiao

No comments:

Post a Comment