fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] Tests for idmapped tmpfs
@ 2023-03-07 11:44 Rodrigo Campos
  2023-03-07 11:44 ` [PATCH 01/11] vfs: Don't open-code safe_close() Rodrigo Campos
                   ` (10 more replies)
  0 siblings, 11 replies; 28+ messages in thread
From: Rodrigo Campos @ 2023-03-07 11:44 UTC (permalink / raw)
  To: fstests; +Cc: Christian Brauner, Giuseppe Scrivano, Rodrigo Campos

Hi!

This patches add tests for tmpfs idmap mounts inside a userns.

Linux 6.3 added idmap mounts support for tmpfs and while the core tests pass and
cover a lot, tmpfs also supports to create an idmap mount inside a userns. So
here we add tests for that: create a userns, mount tmpfs inside the userns, and
verify that all works as expected, even when we create an idmap mount of the
aforementioned tmpfs mount.

To verify that all works fine inside the userns with the tmpfs mount, I reuse
the core tests that exist today, that test extensively (symlinks, hardlinks,
mknod, fscaps, acls, etc.). To do that, there are basically two things:

        * Export core tests we use from tmpfs tests (so not static anymore, and
          add them to the .h)
	* Added a DIR0 constant and create a userns and mount a tmpfs in DIR0
	  (so existing tests using DIR1, DIR2, etc. just work fine) 
	* Create a struct vfstest_info to pass to the core test we call, with
	  the mountpoint and mnt_fd set to the DIR0 mount we just did.

This way, we can just reuse existing core tests from the tmpfs suite.

I'd like to see if there are more interesting tests we can add using tmpfs
specific options, but those are left for another time (I'm not sure, though,
there are more interesting things to test, as uid/gid options are automatically
used when mounting a tmpfs inside a userns).

The first 3 patches are just unrelated simple fixes that I saw while playing with
the code:
  vfs: Don't open-code safe_close()
  vfs: Fix documentation typo
  vfs: Fix race condition on get_userns_fd()

The next patches pave the way to create the tmpfs idmap suite:
  vfs: Make switch_userns set PR_SET_DUMPABLE
  vfs: Specify wether a test is run inside a userns or not
  vfs: Prepare tests in &s_idmapped_mounts to be reused inside a userns
  vfs: Make idmapped core tests public
  vfs: Export test_setup() and test_cleanup()
  vfs: Add DIR0 constant

These test just either fix some bugs that are not hit in the current code (but
we will hit in the tmpfs suite when nesting userns), export core tests, and add
the notion if a test is running inside a userns, in which case it skips
operations that will fail (like mknod on char devices).

Then, the tmpfs suite is added here:
  vfs: Add tmpfs tests for idmap mounts

As described already, it creates a userns, mounts a tmpfs and calls the core
tests we prepared for this. Nothing more, really.

And lastly, one small fix to be consistent and use tabs instead of spaces in the
little amount of places we were not doing that:
  vfs: Use tabs to indent, not spaces

I left this last as moving it to the beginning caused lot of conflicts.

I'll be afk soon, I can catch-up with the review comments next week.


Best,
Rodrigo

Rodrigo Campos (11):
  vfs: Don't open-code safe_close()
  vfs: Fix documentation typo
  vfs: Fix race condition on get_userns_fd()
  vfs: Make switch_userns set PR_SET_DUMPABLE
  vfs: Specify wether a test is run inside a userns or not
  vfs: Prepare tests in &s_idmapped_mounts to be reused inside a userns
  vfs: Make idmapped core tests public
  vfs: Export test_setup() and test_cleanup()
  vfs: Add DIR0 constant
  vfs: Add tmpfs tests for idmap mounts
  vfs: Use tabs to indent, not spaces

 src/vfs/Makefile                |   4 +-
 src/vfs/idmapped-mounts.c       | 190 ++++++++++----------
 src/vfs/idmapped-mounts.h       |  38 ++++
 src/vfs/tmpfs-idmapped-mounts.c | 299 ++++++++++++++++++++++++++++++++
 src/vfs/tmpfs-idmapped-mounts.h |  15 ++
 src/vfs/utils.c                 |  20 +--
 src/vfs/utils.h                 |   6 +-
 src/vfs/vfstest.c               |  46 +++--
 src/vfs/vfstest.h               |  10 ++
 tests/tmpfs/001                 |  27 +++
 tests/tmpfs/001.out             |   2 +
 tests/tmpfs/Makefile            |  24 +++
 12 files changed, 555 insertions(+), 126 deletions(-)
 create mode 100644 src/vfs/tmpfs-idmapped-mounts.c
 create mode 100644 src/vfs/tmpfs-idmapped-mounts.h
 create mode 100644 src/vfs/vfstest.h
 create mode 100755 tests/tmpfs/001
 create mode 100644 tests/tmpfs/001.out
 create mode 100644 tests/tmpfs/Makefile

-- 
2.39.2


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2023-03-13 10:37 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 11:44 [PATCH 00/11] Tests for idmapped tmpfs Rodrigo Campos
2023-03-07 11:44 ` [PATCH 01/11] vfs: Don't open-code safe_close() Rodrigo Campos
2023-03-07 16:42   ` Christian Brauner
2023-03-07 11:44 ` [PATCH 02/11] vfs: Fix documentation typo Rodrigo Campos
2023-03-07 16:43   ` Christian Brauner
2023-03-07 11:44 ` [PATCH 03/11] vfs: Fix race condition on get_userns_fd() Rodrigo Campos
2023-03-07 16:46   ` Christian Brauner
2023-03-07 17:32     ` Rodrigo Campos
2023-03-07 11:45 ` [PATCH 04/11] vfs: Make switch_userns set PR_SET_DUMPABLE Rodrigo Campos
2023-03-07 16:47   ` Christian Brauner
2023-03-07 11:45 ` [PATCH 05/11] vfs: Specify wether a test is run inside a userns or not Rodrigo Campos
2023-03-07 11:45 ` [PATCH 06/11] vfs: Prepare tests in &s_idmapped_mounts to be reused inside a userns Rodrigo Campos
2023-03-07 16:50   ` Christian Brauner
2023-03-07 23:34     ` Rodrigo Campos
2023-03-13 10:37       ` Christian Brauner
2023-03-07 11:45 ` [PATCH 07/11] vfs: Make idmapped core tests public Rodrigo Campos
2023-03-07 16:51   ` Christian Brauner
2023-03-07 11:45 ` [PATCH 08/11] vfs: Export test_setup() and test_cleanup() Rodrigo Campos
2023-03-07 16:51   ` Christian Brauner
2023-03-07 17:11     ` Rodrigo Campos
2023-03-07 11:45 ` [PATCH 09/11] vfs: Add DIR0 constant Rodrigo Campos
2023-03-07 16:53   ` Christian Brauner
2023-03-07 17:33     ` Rodrigo Campos
2023-03-07 11:45 ` [PATCH 10/11] vfs: Add tmpfs tests for idmap mounts Rodrigo Campos
2023-03-07 11:45 ` [PATCH 11/11] vfs: Use tabs to indent, not spaces Rodrigo Campos
2023-03-07 16:55   ` Christian Brauner
2023-03-07 17:10     ` Rodrigo Campos
2023-03-08 17:27     ` Zorro Lang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).