Commit b35c31e4 authored by Zhihao Cheng's avatar Zhihao Cheng Committed by Wang Zhaolong
Browse files

ubifs: dbg_orphan_check: Fix missed key type checking

maillist inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9MWEQ
CVE: NA

Reference: https://lore.kernel.org/lkml/20240410073751.2522830-8-chengzhihao1@huawei.com/T/



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

When selinux/encryption is enabled, xattr entry node is added into TNC
before host inode when creating new file. So it is possible to find
xattr entry without host inode from TNC. Orphan debug checking is called
by ubifs_orphan_end_commit(), at that time, the commit semaphore is
already unlock, so the new creation won't be blocked.

Fixes: d7f0b70d ("UBIFS: Add security.* XATTR support for the UBIFS")
Fixes: d475a507 ("ubifs: Add skeleton for fscrypto")
Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: default avatarZhaoLong Wang <wangzhaolong1@huawei.com>
parent b2cb54bc
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -816,8 +816,12 @@ static int dbg_orphan_check(struct ubifs_info *c, struct ubifs_zbranch *zbr,

	inum = key_inum(c, &zbr->key);
	if (inum != ci->last_ino) {
		/* Lowest node type is the inode node, so it comes first */
		if (key_type(c, &zbr->key) != UBIFS_INO_KEY)
		/*
		 * Lowest node type is the inode node or xattr entry(when
		 * selinux/encryption is enabled), so it comes first
		 */
		if (key_type(c, &zbr->key) != UBIFS_INO_KEY &&
		    key_type(c, &zbr->key) != UBIFS_XENT_KEY)
			ubifs_err(c, "found orphan node ino %lu, type %d",
				  (unsigned long)inum, key_type(c, &zbr->key));
		ci->last_ino = inum;