Commit graph

15 commits

Author SHA1 Message Date
Amir Goldstein
0bd92b9fe5
selftests/filesystems: move wrapper.h out of overlayfs subdir
This is not an overlayfs specific header.

Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/20250509133240.529330-2-amir73il@gmail.com
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-12 11:40:12 +02:00
Christian Brauner
7a012a692e
selftests/mount_settattr: add missing STATX_MNT_ID_UNIQUE define
CC       mount_setattr_test
In file included from mount_setattr_test.c:24:
mount_setattr_test.c: In function ‘mount_setattr_mount_detached_mount_on_detached_mount_and_attach’:
mount_setattr_test.c:1850:60: error: ‘STATX_MNT_ID_UNIQUE’ undeclared (first use in this function); did you mean ‘STATX_MNT_ID’?
 1850 |         ASSERT_EQ(statx(fd_tree_subdir, "", AT_EMPTY_PATH, STATX_MNT_ID_UNIQUE, &stx), 0);
      |                                                            ^~~~~~~~~~~~~~~~~~~
../kselftest_harness.h:757:20: note: in definition of macro ‘__EXPECT’
  757 |         __typeof__(_expected) __exp = (_expected); \
      |                    ^~~~~~~~~
mount_setattr_test.c:1850:9: note: in expansion of macro ‘ASSERT_EQ’
 1850 |         ASSERT_EQ(statx(fd_tree_subdir, "", AT_EMPTY_PATH, STATX_MNT_ID_UNIQUE, &stx), 0);
      |         ^~~~~~~~~
mount_setattr_test.c:1850:60: note: each undeclared identifier is reported only once for each function it appears in
 1850 |         ASSERT_EQ(statx(fd_tree_subdir, "", AT_EMPTY_PATH, STATX_MNT_ID_UNIQUE, &stx), 0);
      |                                                            ^~~~~~~~~~~~~~~~~~~
../kselftest_harness.h:757:20: note: in definition of macro ‘__EXPECT’
  757 |         __typeof__(_expected) __exp = (_expected); \
      |                    ^~~~~~~~~
mount_setattr_test.c:1850:9: note: in expansion of macro ‘ASSERT_EQ’
 1850 |         ASSERT_EQ(statx(fd_tree_subdir, "", AT_EMPTY_PATH, STATX_MNT_ID_UNIQUE, &stx), 0);
      |         ^~~~~~~~~

Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-05-12 11:40:08 +02:00
Linus Torvalds
804382d59b vfs-6.15-rc1.overlayfs
-----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCZ90rUAAKCRCRxhvAZXjc
 opI3AP9ws4S/JXOjxNKoTYmNM2nZ8+r1v8tUxbLIiqdvzx9PygD/V1ZjXtn6lwZr
 OK8d5Y8UnlPZTlBF8D61op3AjnXYzws=
 =KV4p
 -----END PGP SIGNATURE-----

Merge tag 'vfs-6.15-rc1.overlayfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs overlayfs updates from Christian Brauner:
 "Currently overlayfs uses the mounter's credentials for its
  override_creds() calls. That provides a consistent permission model.

  This patches allows a caller to instruct overlayfs to use its
  credentials instead. The caller must be located in the same user
  namespace hierarchy as the user namespace the overlayfs instance will
  be mounted in. This provides a consistent and simple security model.

  With this it is possible to e.g., mount an overlayfs instance where
  the mounter must have CAP_SYS_ADMIN but the credentials used for
  override_creds() have dropped CAP_SYS_ADMIN. It also allows the usage
  of custom fs{g,u}id different from the callers and other tweaks"

* tag 'vfs-6.15-rc1.overlayfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
  selftests/ovl: add third selftest for "override_creds"
  selftests/ovl: add second selftest for "override_creds"
  selftests/filesystems: add utils.{c,h}
  selftests/ovl: add first selftest for "override_creds"
  ovl: allow to specify override credentials
2025-03-24 10:37:40 -07:00
Christian Brauner
a1579f6bf6
selftests/ovl: add third selftest for "override_creds"
Add a simple test to verify that the new "override_creds" option works.

Link: https://lore.kernel.org/r/20250219-work-overlayfs-v3-4-46af55e4ceda@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-19 14:32:12 +01:00
Christian Brauner
6e5ed6587e
selftests/ovl: add second selftest for "override_creds"
Add a simple test to verify that the new "override_creds" option works.

Link: https://lore.kernel.org/r/20250219-work-overlayfs-v3-3-46af55e4ceda@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-19 14:32:12 +01:00
Christian Brauner
c68946ee7e
selftests/filesystems: add utils.{c,h}
Add a new set of helpers that will be used in follow-up patches.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-19 14:32:12 +01:00
Christian Brauner
96f0943259
selftests/ovl: add first selftest for "override_creds"
Add a simple test to verify that the new "override_creds" option works.

Link: https://lore.kernel.org/r/20250219-work-overlayfs-v3-2-46af55e4ceda@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-19 14:32:12 +01:00
Christian Brauner
ccc829b15d
selftests: add tests for using detached mount with overlayfs
Test that it is possible to use detached mounts as overlayfs layers.

Link: https://lore.kernel.org/r/20250123-erstbesteigung-angeeignet-1d30e64b7df2@brauner
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-12 12:12:27 +01:00
Christian Brauner
85c8700cb6
selftests/overlayfs: test specifying layers as O_PATH file descriptors
Verify that userspace can specify layers via O_PATH file descriptors.

Link: https://lore.kernel.org/r/20250210-work-overlayfs-v2-2-ed2a949b674b@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-12 10:02:11 +01:00
Christian Brauner
d59dfd625a
selftests: add test for specifying 500 lower layers
Verify that we can actually specify 500 lower layers and fail at the
501st one.

Link: https://lore.kernel.org/r/20241015-leiht-filmabend-a86eed4ff304@brauner
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-10-15 14:39:35 +02:00
Christian Brauner
af9199145b
selftests: add overlayfs fd mounting selftests
Link: https://lore.kernel.org/r/20241014-work-overlayfs-v3-5-32b3fed1286e@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-10-14 16:31:17 +02:00
Christian Brauner
e94fdd5d9a
selftests: use shared header
So that we don't have to redefine the same system calls over and over.

Link: https://lore.kernel.org/r/20241014-work-overlayfs-v3-4-32b3fed1286e@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-10-14 16:31:16 +02:00
Michael Ellerman
e8b8c5264d selftests/overlayfs: Fix build error on ppc64
Fix build error on ppc64:
  dev_in_maps.c: In function ‘get_file_dev_and_inode’:
  dev_in_maps.c:60:59: error: format ‘%llu’ expects argument of type
  ‘long long unsigned int *’, but argument 7 has type ‘__u64 *’ {aka ‘long
  unsigned int *’} [-Werror=format=]

By switching to unsigned long long for u64 for ppc64 builds.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-05-29 12:26:40 -06:00
Hu Yadi
0f05ee4479 selftests/filesystems:fix build error in overlayfs
One build issue comes up due to both mount.h included dev_in_maps.c

In file included from dev_in_maps.c:10:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
   35 |   MS_RDONLY = 1,  /* Mount read-only.  */
      |   ^~~~~~~~~
In file included from dev_in_maps.c:13:

Remove one of them to solve conflict, another error comes up:

dev_in_maps.c:170:6: error: implicit declaration of function ‘mount’ [-Werror=implicit-function-declaration]
  170 |  if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
      |      ^~~~~
cc1: all warnings being treated as errors

and then , add sys_mount definition to solve it
After both above, dev_in_maps.c can be built correctly on my mache(gcc 10.2,glibc-2.32,kernel-5.10)

Signed-off-by: Hu Yadi <hu.yadi@h3c.com>
Link: https://lore.kernel.org/r/20240112074059.29673-1-hu.yadi@h3c.com
Acked-by: Andrei Vagin <avagin@google.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2024-01-22 15:33:37 +01:00
Andrei Vagin
b5a78c7127
selftests/overlayfs: verify device and inode numbers in /proc/pid/maps
When mapping a file on overlayfs, the file stored in ->vm_file is a
backing file whose f_inode is on the underlying filesystem. We need to
verify that /proc/pid/maps contains numbers of the overlayfs file, but
not its backing file.

Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Signed-off-by: Andrei Vagin <avagin@google.com>
Link: https://lore.kernel.org/r/20231214064439.1023011-2-avagin@google.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2023-12-21 13:17:54 +01:00