All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Campos <rodrigo@sdfg.com.ar>
To: fstests@vger.kernel.org
Cc: Christian Brauner <brauner@kernel.org>,
	Giuseppe Scrivano <gscrivan@redhat.com>,
	Rodrigo Campos <rodrigo@sdfg.com.ar>
Subject: [PATCH 00/11] Tests for idmapped tmpfs
Date: Tue,  7 Mar 2023 12:44:56 +0100	[thread overview]
Message-ID: <20230307114507.332309-1-rodrigo@sdfg.com.ar> (raw)

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


             reply	other threads:[~2023-03-07 12:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 11:44 Rodrigo Campos [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230307114507.332309-1-rodrigo@sdfg.com.ar \
    --to=rodrigo@sdfg.com.ar \
    --cc=brauner@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=gscrivan@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.