Skip to content

RFC pidfs: file handle preliminaries

Christian Brauner linux-fsdevel linux-nfs lkml 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20241128-work-pidfs-2bd42c7ea772

Versions newest first

  1. v2 RFC Latest3 patches 5 repliesIn review
  2. v1 RFC2 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Remove __maybe_unused pidfd_ino_get_pid() function that was only there for initial illustration purposes.
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3pidfs: rework inode number allocationfs/pidfs.c include/linux/pidfs.h kernel/pid.c+72 -71 reply
2/3pidfs: remove 32bit inode number handlingfs/pidfs.c+5 -411 reply
3/3pidfs: support FS_IOC_GETVERSIONfs/pidfs.c+9 -01 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAmir GoldsteinJeff LaytonJan Kara
SeriesR-b R-b R-b R-b R-b R-b R-b R-b R-b R-b
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH RFC v2 0/3] pidfs: file handle preliminaries

Hey,

This reworks the inode number allocation for pidfs in order to support file handles properly.

Recently we received a patchset that aims to enable file handle encoding and decoding via name_to_handle_at(2) and open_by_handle_at(2).

A crucical step in the patch series is how to go from inode number to struct pid without leaking information into unprivileged contexts. The issue is that in order to find a struct pid the pid number in the initial pid namespace must be encoded into the file handle via name_to_handle_at(2). This can be used by containers using a separate pid namespace to learn what the pid number of a given process in the initial pid namespace is. While this is a weak information leak it could be used in various exploits and in general is an ugly wart in the design.

To solve this problem a new way is needed to lookup a struct pid based on the inode number allocated for that struct pid. The other part is to remove the custom inode number allocation on 32bit systems that is also an ugly wart that should go away.

So, a new scheme is used that I was discusssing with Tejun some time back. A cyclic ida is used for the lower 32 bits and a the high 32 bits are used for the generation number. This gives a 64 bit inode number that is unique on both 32 bit and 64 bit. The lower 32 bit number is recycled slowly and can be used to lookup struct pids.

Thanks!
Christian

---
Changes in v2:
- Remove __maybe_unused pidfd_ino_get_pid() function that was only there for initial illustration purposes.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Christian Brauner (3):
pidfs: rework inode number allocation
pidfs: remove 32bit inode number handling
pidfs: support FS_IOC_GETVERSION

 fs/pidfs.c            | 118 ++++++++++++++++++++++++++++++++------------------
 include/linux/pidfs.h |   2 +
 kernel/pid.c          |  14 +++---
 3 files changed, 86 insertions(+), 48 deletions(-)

---
base-commit: b86545e02e8c22fb89218f29d381fa8e8b91d815
change-id: 20241128-work-pidfs-2bd42c7ea772