All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ocfs2: reject orphaned dinodes with non-zero link count
@ 2026-06-04 11:59 Dmitry Antipov
  2026-06-05  1:49 ` Heming Zhao
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2026-06-04 11:59 UTC (permalink / raw)
  To: Joseph Qi
  Cc: Joel Becker, Mark Fasheh, ocfs2-devel, lvc-project,
	Dmitry Antipov, syzbot+5bdd4953bc58c8fbd6eb

Since non-zero link count for an orphaned inode most likely
means that on-disk inode data is corrupted, reject such an
inodes in 'ocfs2_validate_inode_block()'.

Reported-by: syzbot+5bdd4953bc58c8fbd6eb@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5bdd4953bc58c8fbd6eb
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
I'm quite sure about Closes: but was unable to test this using syzbot due to
"FATAL: kernel too old" issues (most likely caused by the kernel vs. glibc
mismatch) like https://syzkaller.appspot.com/x/log.txt?x=13f51bec580000.
---
 fs/ocfs2/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index a510a0eb1adc..d483e0c61d12 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1477,6 +1477,15 @@ int ocfs2_validate_inode_block(struct super_block *sb,
 		goto bail;
 	}
 
+	if ((le32_to_cpu(di->i_flags) & OCFS2_ORPHANED_FL) &&
+	    ocfs2_read_links_count(di)) {
+		rc = ocfs2_error(sb,
+				 "Invalid dinode #%llu: orphaned with %u links\n",
+				 (unsigned long long)bh->b_blocknr,
+				 ocfs2_read_links_count(di));
+		goto bail;
+	}
+
 	if (le32_to_cpu(di->i_fs_generation) !=
 	    OCFS2_SB(sb)->fs_generation) {
 		rc = ocfs2_error(sb,
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-05  1:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 11:59 [PATCH] ocfs2: reject orphaned dinodes with non-zero link count Dmitry Antipov
2026-06-05  1:49 ` Heming Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.