fs/proc: show correct device and inode numbers in /proc/pid/maps
authorAndrei Vagin <avagin@google.com>
Thu, 14 Dec 2023 06:44:38 +0000 (22:44 -0800)
committerChristian Brauner <brauner@kernel.org>
Thu, 21 Dec 2023 12:17:54 +0000 (13:17 +0100)
commit3efdc78fdc21ab82694707eb234ab93f28d13ba8
treec8d8474c4044416931c05db19283882fe6544e9c
parent434225230081b2b3435703decfa9c4214aac22ce
fs/proc: show correct device and inode numbers in /proc/pid/maps

/proc/pid/maps shows device and inode numbers of vma->vm_file-s. Here is
an issue. If a mapped file is on a stackable file system (e.g.,
overlayfs), vma->vm_file is a backing file whose f_inode is on the
underlying filesystem. To show correct numbers, we need to get a user
file and shows its numbers. The same trick is used to show file paths in
/proc/pid/maps.

Cc: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Suggested-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Andrei Vagin <avagin@google.com>
Link: https://lore.kernel.org/r/20231214064439.1023011-1-avagin@google.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/proc/task_mmu.c
include/linux/fs.h