ceph: fix up non-directory creation in SGID directories
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 29 Nov 2021 11:16:39 +0000 (12:16 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 1 Dec 2021 16:08:27 +0000 (17:08 +0100)
commitfd84bfdddd169c219c3a637889a8b87f70a072c2
tree6de9fbabdf6699f933b2d49af676aacad3faf396
parentee2a095d3b24f300a5e11944d208801e928f108c
ceph: fix up non-directory creation in SGID directories

Ceph always inherits the SGID bit if it is set on the parent inode,
while the generic inode_init_owner does not do this in a few cases where
it can create a possible security problem (cf. [1]).

Update ceph to strip the SGID bit just as inode_init_owner would.

This bug was detected by the mapped mount testsuite in [3]. The
testsuite tests all core VFS functionality and semantics with and
without mapped mounts. That is to say it functions as a generic VFS
testsuite in addition to a mapped mount testsuite. While working on
mapped mount support for ceph, SIGD inheritance was the only failing
test for ceph after the port.

The same bug was detected by the mapped mount testsuite in XFS in
January 2021 (cf. [2]).

[1]: commit 0fa3ecd87848 ("Fix up non-directory creation in SGID directories")
[2]: commit 01ea173e103e ("xfs: fix up non-directory creation in SGID directories")
[3]: https://git.kernel.org/fs/xfs/xfstests-dev.git

Cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/file.c