lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f2ui7rofuos4vcuj7t7pa5tcyq5m3agm44ouk7hcdl7opiwmwd@dyctf7rrsuqw>
Date: Wed, 10 Dec 2025 12:00:22 +0100
From: Mateusz Guzik <mjguzik@...il.com>
To: syzbot <syzbot+d222f4b7129379c3d5bc@...kaller.appspotmail.com>
Cc: brauner@...nel.org, jack@...e.cz, jlbec@...lplan.org, 
	joseph.qi@...ux.alibaba.com, linkinjeon@...nel.org, linux-fsdevel@...r.kernel.org, 
	linux-kernel@...r.kernel.org, mark@...heh.com, ocfs2-devel@...ts.linux.dev, 
	sj1557.seo@...sung.com, syzkaller-bugs@...glegroups.com, viro@...iv.linux.org.uk
Subject: Re: [syzbot] [exfat?] [ocfs2?] kernel BUG in link_path_walk

the spin lock is needed because there are *two* fields being checked.
I am not adding explicit memory barriers for smething like this.

#syz test

diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 0ef9bcb744dd..8e9127d4dcc1 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -207,11 +207,17 @@ void make_bad_inode(struct inode *inode)
 {
 	remove_inode_hash(inode);
 
+	/*
+	 * Taking the spinlock is a temporary hack to let lookup assert on the state,
+	 * see lookup_inode_permission_may_exec().
+	 */
+	spin_lock(&inode->i_lock);
 	inode->i_mode = S_IFREG;
 	simple_inode_init_ts(inode);
 	inode->i_op = &bad_inode_ops;	
 	inode->i_opflags &= ~IOP_XATTR;
 	inode->i_fop = &bad_file_ops;	
+	spin_unlock(&inode->i_lock);
 }
 EXPORT_SYMBOL(make_bad_inode);
 
diff --git a/fs/namei.c b/fs/namei.c
index bf0f66f0e9b9..f2a0f858b7d6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -626,9 +626,26 @@ EXPORT_SYMBOL(inode_permission);
 static __always_inline int lookup_inode_permission_may_exec(struct mnt_idmap *idmap,
 	struct inode *inode, int mask)
 {
-	/* Lookup already checked this to return -ENOTDIR */
-	VFS_BUG_ON_INODE(!S_ISDIR(inode->i_mode), inode);
 	VFS_BUG_ON((mask & ~MAY_NOT_BLOCK) != 0);
+#ifdef CONFIG_DEBUG_VFS
+	/*
+	 * We skip the type check on the assumption this is a directory, which was
+	 * checked for by our caller.
+	 *
+	 * However, there are bogus consumers of make_bad_inode() which can mess this up,
+	 * to be fixed soon(tm).
+	 *
+	 * In the meantime make sure we are dealing with the expected state before tripping
+	 * over. If this *is* a "bad inode", the resulting state is bug-compatible with
+	 * historical behavior. See the previous remark about sorting this out.
+	 */
+	if (!S_ISDIR(inode->i_mode)) {
+		spin_lock(&inode->i_lock);
+		if (!is_bad_inode(inode))
+			VFS_BUG_ON_INODE(!S_ISDIR(inode->i_mode), inode);
+		spin_unlock(&inode->i_lock);
+	}
+#endif
 
 	mask |= MAY_EXEC;
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ