The Linux kernel requires sudo
for /proc/<pid>/pagemap
since 4.0
This is documented at:https://github.com/torvalds/linux/blob/v4.9/Documentation/vm/pagemap.txt
Since Linux 4.0 only users with the CAP_SYS_ADMIN capability can get PFNs. In 4.0 and 4.1 opens by unprivileged fail with -EPERM. Starting from 4.2 the PFN field is zeroed if the user does not have CAP_SYS_ADMIN. Reason: information about PFNs helps in exploiting Rowhammer vulnerability.
Where CAP_SYS_ADMIN
basically means "run as sudo
", or alternatively:
sudo setcap cap_sys_admin+ep program_that_uses_pagemap./program_that_uses_pagemap
Keep in mind that /proc
is a virtual filesystem, and so the Linux kernel can choose to enforce additional permissions or even alter results arbitrarily for non root as it does here for security reasons by setting PFNs to zero.