Skip to content

fs: harden anon inodes

Christian Brauner linux-fsdevel stable 1 version In review

Get series with b4
b4 am [email protected] change-id 20250407-work-anon_inode-e22bb1a74992

Versions newest first

  1. v1 Latest9 patches 21 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9anon_inode: use a proper mode internallyfs/anon_inodes.c fs/internal.h fs/libfs.c+40 -19 replies
2/9pidfs: use anon_inode_getattr()fs/pidfs.c+1 -231 reply
3/9anon_inode: explicitly block ->setattr()fs/anon_inodes.c fs/internal.h+9 -01 reply
4/9pidfs: use anon_inode_setattr()fs/pidfs.c+1 -11 reply
5/9anon_inode: raise SB_I_NODEV and SB_I_NOEXECfs/anon_inodes.c+2 -02 replies
6/9selftests/filesystems: add first test for anonymous inodestools/testing/selftests/filesystems/.gitignore tools/testing/selftests/filesystems/Makefile tools/testing/selftests/filesystems/anon_inode_test.c+28 -11 reply
7/9selftests/filesystems: add second test for anonymous inodestools/testing/selftests/filesystems/anon_inode_test.c+13 -01 reply
8/9selftests/filesystems: add third test for anonymous inodestools/testing/selftests/filesystems/anon_inode_test.c+13 -01 reply
9/9selftests/filesystems: add fourth test for anonymous inodestools/testing/selftests/filesystems/anon_inode_test.c+17 -01 reply

Reviews trailers per patch

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

PatchJeff LaytonJan Kara
SeriesR-b
1/9R-b
2/9R-b
3/9R-b
4/9R-b
5/9R-b
6/9R-b
7/9R-b
8/9R-b
9/9R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/9] fs: harden anon inodes

* Anonymous inodes currently don't come with a proper mode causing issues in the kernel when we want to add useful VFS debug assert. Fix that by giving them a proper mode and masking it off when we report it to userspace which relies on them not having any mode.

* Anonymous inodes currently allow to change inode attributes because the VFS falls back to simple_setattr() if i_op->setattr isn't implemented. This means the ownership and mode for every single user of anon_inode_inode can be changed. Block that as it's either useless or actively harmful. If specific ownership is needed the respective subsystem should allocate anonymous inodes from their own private superblock.

* Port pidfs to the new anon_inode_{g,s}etattr() helpers.

* Add proper tests for anonymous inode behavior.

The anonymous inode specific fixes should ideally be backported to all LTS kernels.

---
Christian Brauner (9):
anon_inode: use a proper mode internally
pidfs: use anon_inode_getattr()
anon_inode: explicitly block ->setattr()
pidfs: use anon_inode_setattr()
anon_inode: raise SB_I_NODEV and SB_I_NOEXEC selftests/filesystems: add first test for anonymous inodes selftests/filesystems: add second test for anonymous inodes selftests/filesystems: add third test for anonymous inodes selftests/filesystems: add fourth test for anonymous inodes

 fs/anon_inodes.c                                   | 45 ++++++++++++++
 fs/internal.h                                      |  5 ++
 fs/libfs.c                                         |  2 +-
 fs/pidfs.c                                         | 26 +-------
 tools/testing/selftests/filesystems/.gitignore     |  1 +
 tools/testing/selftests/filesystems/Makefile       |  2 +-
 .../selftests/filesystems/anon_inode_test.c        | 69 ++++++++++++++++++++++
 7 files changed, 124 insertions(+), 26 deletions(-)

---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250407-work-anon_inode-e22bb1a74992