idmapped-mounts: Add mknodat operation in setgid test
authorYang Xu <xuyang2018.jy@fujitsu.com>
Sat, 7 May 2022 16:01:26 +0000 (00:01 +0800)
committerZorro Lang <zlang@kernel.org>
Sat, 7 May 2022 15:08:34 +0000 (23:08 +0800)
commit5328ab947ff4d2d492a6ac90b22d31ab02637bd8
tree032f78be873ebdb8556621787ccc00bced6267a1
parent6ac390bb605b70ef9d12eff9742379e13cfe0cd6
idmapped-mounts: Add mknodat operation in setgid test

Since mknodat can create file, we should also check whether strip S_ISGID.
Also add new helper caps_down_fsetid to drop CAP_FSETID because strip S_ISGID
depend on this cap and keep other cap(ie CAP_MKNOD) because create character
device needs it when using mknod.

Only test mknodat with character device in setgid_create function and the another
two functions test mknodat with whiteout device.

Since kernel commit a3c751a50 ("vfs: allow unprivileged whiteout creation") in
v5.8-rc1, we can create whiteout device in userns test. Since kernel 5.12, mount_setattr
and MOUNT_ATTR_IDMAP was supported, we don't need to detect kernel whether allow
unprivileged whiteout creation. Using fs_allow_idmap as a proxy is safe.

Tested-by: Christian Brauner (Microsoft)<brauner@kernel.org>
Reviewed-by: Christian Brauner (Microsoft)<brauner@kernel.org>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/idmapped-mounts/idmapped-mounts.c