Skip to contentSkip to conversation

process /proc/PID/smaps vs /proc/PID/smaps_rollup

RFC Sergey Senozhatsky 2 participants 3 messages Sep 29, 2020 – Sep 8, 2022 VFS

lore
Share & tools
lore
#0 lore raw

Hello,

One of our unprivileged daemon process needs process PSS info. That info is usually available in /proc/PID/smaps on per-vma basis, on in /proc/PID/smaps_rollup as a bunch of accumulated per-vma values. The latter one is much faster and simpler to get, but, unlike smaps, smaps_rollup requires PTRACE_MODE_READ, which we don't want to grant to our unprivileged daemon.

So the question is - can we get, somehow, accumulated PSS info from a non-privileged process? (Iterating through all process' smaps vma-s consumes quite a bit of CPU time). This is related to another question - why do smaps and smaps_rollup have different permission requirements?

	-ss
#1 lore raw
Quoted 9 lines · Sergey Senozhatsky

Hello,

One of our unprivileged daemon process needs process PSS info. That info is usually available in /proc/PID/smaps on per-vma basis, on in /proc/PID/smaps_rollup as a bunch of accumulated per-vma values. The latter one is much faster and simpler to get, but, unlike smaps, smaps_rollup requires PTRACE_MODE_READ, which we don't want to grant to our unprivileged daemon.

Quoted 5 lines

So the question is - can we get, somehow, accumulated PSS info from a non-privileged process? (Iterating through all process' smaps vma-s consumes quite a bit of CPU time). This is related to another question - why do smaps and smaps_rollup have different permission requirements?

Hold on, seems that I misread something, /proc/PID/smaps is also unavailable. So the question is, then, how do we get PSS info of a random user-space process from an unprivileged daemon?

	-ss
#2 lore raw
Quoted 14 lines · Sergey Senozhatsky
Quoted 7 lines · Sergey Senozhatsky

One of our unprivileged daemon process needs process PSS info. That info is usually available in /proc/PID/smaps on per-vma basis, on in /proc/PID/smaps_rollup as a bunch of accumulated per-vma values. The latter one is much faster and simpler to get, but, unlike smaps, smaps_rollup requires PTRACE_MODE_READ, which we don't want to grant to our unprivileged daemon.

Quoted 5 lines

So the question is - can we get, somehow, accumulated PSS info from a non-privileged process? (Iterating through all process' smaps vma-s consumes quite a bit of CPU time). This is related to another question - why do smaps and smaps_rollup have different permission requirements?

Quoted 3 lines

Hold on, seems that I misread something, /proc/PID/smaps is also unavailable. So the question is, then, how do we get PSS info of a random user-space process from an unprivileged daemon?

smaps contains a lot of sensitive information, but perhaps smaps_rollup could be allowed without ptrace rights if the range information is masked. I've posted a patch here:

https://lore.kernel.org/linux-mm/[email protected]/