mmap on /proc/pid/mem
Asked Answered
A

1

16

Has anybody succeeded in mmap'ing a /proc/pid/mem file with Linux kernel 2.6? I am getting an ENODEV (No such device) error. My call looks like this:

char * map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, mem_fd, offset);

And I have verified by looking at the /proc/pid/maps file while debugging that, when execution reaches this call, offset has the value of the top of the stack minus PAGE_SIZE. I have also verified with ptrace that mmap is setting errno to ENODEV.

Arica answered 7/3, 2011 at 5:52 Comment(0)
T
26

See proc_mem_operations in /usr/src/linux/fs/proc/base.c: /proc/.../mem does not support mmap.

The respecitve linux kernel source can be installed via the linux-source package or by sourcing it directly from kernel.org

Testicle answered 7/3, 2011 at 6:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.