Linux-mtd Archive mirror
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<yi.zhang@huawei.com>
Subject: [PATCH 9/9] ubifs: dbg_orphan_check: Fix missed key type checking
Date: Wed, 10 Apr 2024 15:37:51 +0800	[thread overview]
Message-ID: <20240410073751.2522830-10-chengzhihao1@huawei.com> (raw)
In-Reply-To: <20240410073751.2522830-1-chengzhihao1@huawei.com>

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: d7f0b70d30ff ("UBIFS: Add security.* XATTR support for the UBIFS")
Fixes: d475a507457b ("ubifs: Add skeleton for fscrypto")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 fs/ubifs/orphan.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index 37d206097112..fb957d963ba6 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -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;
-- 
2.39.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      parent reply	other threads:[~2024-04-10  7:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10  7:37 [PATCH 0/9] ubifs: Fix a serious of inconsistent problems when powercut happens Zhihao Cheng
2024-04-10  7:37 ` [PATCH 1/9] ubifs: Fix unattached xattr inode if powercut happens after deleting Zhihao Cheng
2024-04-10  7:37 ` [PATCH 2/9] ubifs: Don't add xattr inode into orphan area Zhihao Cheng
2024-04-10  7:37 ` [PATCH 3/9] Revert "ubifs: ubifs_symlink: Fix memleak of inode->i_link in error path" Zhihao Cheng
2024-04-10  7:37 ` [PATCH 4/9] ubifs: Remove insert_dead_orphan from replaying orphan process Zhihao Cheng
2024-04-10  7:37 ` [PATCH 5/9] ubifs: Fix adding orphan entry twice for the same inode Zhihao Cheng
2024-04-10  7:37 ` [PATCH 6/9] ubifs: Move ui->data initialization after initializing security Zhihao Cheng
2024-04-10  7:37 ` [PATCH 7/9] ubifs: Fix space leak when powercut happens in linking tmpfile Zhihao Cheng
2024-04-10  7:37 ` [PATCH 8/9] ubifs: Fix unattached inode when powercut happens in creating Zhihao Cheng
2024-04-10  7:37 ` Zhihao Cheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240410073751.2522830-10-chengzhihao1@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).