Re: [syzbot ci] Re: minix: convert to iomap and add direct I/O

Jeremy Bingham <[email protected]>
Newsgroups dev.linux.lists.syzbot,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
#syz test

minix: add the same dentry check as ext4_get_link to minix_get_link

It turns out that minix_get_link does need to have both the sb_bread and
the sb_getblk paths, like ext4_get_link does. It working with just the
sb_bread one initially was deceptive.
---
 fs/minix/namei.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index e245f55a68ff..a4caaa3f7c9a 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -393,12 +393,23 @@ const char *minix_get_link(struct dentry *dentry, struct inode *inode,
 	else
 		blk = v2_block_to_cpu(*(v2_i_data(inode)));
 
-	bh = sb_bread(sb, blk);
-	if (IS_ERR(bh))
-		return ERR_CAST(bh);
-	if (!bh) {
-		pr_err("bad symlink on inode %llu", inode->i_ino);
-		return ERR_PTR(-EFSCORRUPTED);
+	/* This tried dodging the dentry check that ext4 does, but it turns out
+	 * that it's necessary after all.
+	 */
+	if (!dentry) {
+		bh = sb_getblk(sb, blk);
+		if (!bh || !buffer_uptodate(bh)) {
+			brelse(bh);
+			return ERR_PTR(-ECHILD);
+		}
+	} else {
+		bh = sb_bread(sb, blk);
+		if (IS_ERR(bh))
+			return ERR_CAST(bh);
+		if (!bh) {
+			pr_err("bad symlink on inode %llu", inode->i_ino);
+			return ERR_PTR(-EFSCORRUPTED);
+		}
 	}
 
 	set_delayed_call(callback, minix_free_link, bh);
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.