Commit 0a6d21a3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Zheng Zengkai
Browse files

xfs: fix up non-directory creation in SGID directories

mainline inclusion
from mainline-v5.11-rc4
commit 01ea173e
category: bugfix
bugzilla: 185881 https://gitee.com/openeuler/kernel/issues/I4DDEL
CVE: CVE-2021-4037

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=01ea173e103edd5ec41acec65b9261b87e123fc2



-------------------------------------------------

XFS 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, see commit 0fa3ecd8
("Fix up non-directory creation in SGID directories") for details.

Switch XFS to use the generic helper for the normal path to fix this,
just keeping the simple field inheritance open coded for the case of the
non-sgid case with the bsdgrpid mount option.

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Reported-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>

conflicts:
fs/xfs/xfs_inode.c

Signed-off-by: default avatarGuo Xuenan <guoxuenan@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: default avatarChen Jun <chenjun102@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 9c7e37e5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment