* [PATCH] jfs: Verify inode mode when loading from disk
@ 2025-08-10 14:55 Tetsuo Handa
2025-08-29 13:16 ` Tetsuo Handa
0 siblings, 1 reply; 5+ messages in thread
From: Tetsuo Handa @ 2025-08-10 14:55 UTC (permalink / raw)
To: Dave Kleikamp, jfs-discussion; +Cc: LKML
The inode mode loaded from corrupted disk can be invalid. Do like what
commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk")
does.
Reported-by: syzbot <syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
fs/jfs/inode.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index fcedeb514e14..21f3d029da7d 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -59,9 +59,15 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
*/
inode->i_link[inode->i_size] = '\0';
}
- } else {
+ } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
+ S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
inode->i_op = &jfs_file_inode_operations;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
+ } else {
+ printk(KERN_DEBUG "JFS: Invalid file type 0%04o for inode %lu.\n",
+ inode->i_mode, inode->i_ino);
+ iget_failed(inode);
+ return ERR_PTR(-EIO);
}
unlock_new_inode(inode);
return inode;
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] jfs: Verify inode mode when loading from disk 2025-08-10 14:55 [PATCH] jfs: Verify inode mode when loading from disk Tetsuo Handa @ 2025-08-29 13:16 ` Tetsuo Handa 2025-09-12 14:18 ` [PATCH (REPOST)] " Tetsuo Handa 0 siblings, 1 reply; 5+ messages in thread From: Tetsuo Handa @ 2025-08-29 13:16 UTC (permalink / raw) To: Dave Kleikamp, jfs-discussion; +Cc: LKML, Christian Brauner, Andrew Morton Any questions? Should I find someone who can take this patch? On 2025/08/10 23:55, Tetsuo Handa wrote: > The inode mode loaded from corrupted disk can be invalid. Do like what > commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk") > does. > > Reported-by: syzbot <syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com> > Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > --- > fs/jfs/inode.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c > index fcedeb514e14..21f3d029da7d 100644 > --- a/fs/jfs/inode.c > +++ b/fs/jfs/inode.c > @@ -59,9 +59,15 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino) > */ > inode->i_link[inode->i_size] = '\0'; > } > - } else { > + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || > + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { > inode->i_op = &jfs_file_inode_operations; > init_special_inode(inode, inode->i_mode, inode->i_rdev); > + } else { > + printk(KERN_DEBUG "JFS: Invalid file type 0%04o for inode %lu.\n", > + inode->i_mode, inode->i_ino); > + iget_failed(inode); > + return ERR_PTR(-EIO); > } > unlock_new_inode(inode); > return inode; ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH (REPOST)] jfs: Verify inode mode when loading from disk 2025-08-29 13:16 ` Tetsuo Handa @ 2025-09-12 14:18 ` Tetsuo Handa 2025-09-12 15:05 ` Darrick J. Wong 2025-09-17 18:21 ` Dave Kleikamp 0 siblings, 2 replies; 5+ messages in thread From: Tetsuo Handa @ 2025-09-12 14:18 UTC (permalink / raw) To: Christian Brauner, Andrew Morton, linux-fsdevel Cc: LKML, Dave Kleikamp, jfs-discussion The inode mode loaded from corrupted disk can be invalid. Do like what commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk") does. Reported-by: syzbot <syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com> Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> --- This fix is similar to fixes for other filesystems, but got no response. Do we have to wait for Ack from Dave Kleikamp for another month? fs/jfs/inode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index fcedeb514e14..21f3d029da7d 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -59,9 +59,15 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino) */ inode->i_link[inode->i_size] = '\0'; } - } else { + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { inode->i_op = &jfs_file_inode_operations; init_special_inode(inode, inode->i_mode, inode->i_rdev); + } else { + printk(KERN_DEBUG "JFS: Invalid file type 0%04o for inode %lu.\n", + inode->i_mode, inode->i_ino); + iget_failed(inode); + return ERR_PTR(-EIO); } unlock_new_inode(inode); return inode; -- 2.51.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH (REPOST)] jfs: Verify inode mode when loading from disk 2025-09-12 14:18 ` [PATCH (REPOST)] " Tetsuo Handa @ 2025-09-12 15:05 ` Darrick J. Wong 2025-09-17 18:21 ` Dave Kleikamp 1 sibling, 0 replies; 5+ messages in thread From: Darrick J. Wong @ 2025-09-12 15:05 UTC (permalink / raw) To: Tetsuo Handa Cc: Christian Brauner, Andrew Morton, linux-fsdevel, LKML, Dave Kleikamp, jfs-discussion On Fri, Sep 12, 2025 at 11:18:44PM +0900, Tetsuo Handa wrote: > The inode mode loaded from corrupted disk can be invalid. Do like what > commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk") > does. > > Reported-by: syzbot <syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com> > Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > --- > This fix is similar to fixes for other filesystems, but got no response. > Do we have to wait for Ack from Dave Kleikamp for another month? Let's hope not, this is a validation issue... > fs/jfs/inode.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c > index fcedeb514e14..21f3d029da7d 100644 > --- a/fs/jfs/inode.c > +++ b/fs/jfs/inode.c > @@ -59,9 +59,15 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino) > */ > inode->i_link[inode->i_size] = '\0'; > } > - } else { > + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || > + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { > inode->i_op = &jfs_file_inode_operations; > init_special_inode(inode, inode->i_mode, inode->i_rdev); > + } else { > + printk(KERN_DEBUG "JFS: Invalid file type 0%04o for inode %lu.\n", > + inode->i_mode, inode->i_ino); > + iget_failed(inode); > + return ERR_PTR(-EIO); ...but how about EFSCORRUPTED instead of EIO here? Several filesystems (xfs, ext*, erofs, f2fs, fuse, ocfs2, udf) return that for corrupt metadata. --D > } > unlock_new_inode(inode); > return inode; > -- > 2.51.0 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH (REPOST)] jfs: Verify inode mode when loading from disk 2025-09-12 14:18 ` [PATCH (REPOST)] " Tetsuo Handa 2025-09-12 15:05 ` Darrick J. Wong @ 2025-09-17 18:21 ` Dave Kleikamp 1 sibling, 0 replies; 5+ messages in thread From: Dave Kleikamp @ 2025-09-17 18:21 UTC (permalink / raw) To: Tetsuo Handa, Christian Brauner, Andrew Morton, linux-fsdevel Cc: LKML, Dave Kleikamp, jfs-discussion On 9/12/25 9:18AM, Tetsuo Handa wrote: > The inode mode loaded from corrupted disk can be invalid. Do like what > commit 0a9e74051313 ("isofs: Verify inode mode when loading from disk") > does. > > Reported-by: syzbot <syzbot+895c23f6917da440ed0d@syzkaller.appspotmail.com> > Closes: https://syzkaller.appspot.com/bug?extid=895c23f6917da440ed0d > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > --- > This fix is similar to fixes for other filesystems, but got no response. > Do we have to wait for Ack from Dave Kleikamp for another month? I apologize that it's taken me this long. I'm applying this patch to jfs-next (after a sanity test). Thanks, Shaggy > > fs/jfs/inode.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c > index fcedeb514e14..21f3d029da7d 100644 > --- a/fs/jfs/inode.c > +++ b/fs/jfs/inode.c > @@ -59,9 +59,15 @@ struct inode *jfs_iget(struct super_block *sb, unsigned long ino) > */ > inode->i_link[inode->i_size] = '\0'; > } > - } else { > + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || > + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { > inode->i_op = &jfs_file_inode_operations; > init_special_inode(inode, inode->i_mode, inode->i_rdev); > + } else { > + printk(KERN_DEBUG "JFS: Invalid file type 0%04o for inode %lu.\n", > + inode->i_mode, inode->i_ino); > + iget_failed(inode); > + return ERR_PTR(-EIO); > } > unlock_new_inode(inode); > return inode; ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-17 18:22 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-08-10 14:55 [PATCH] jfs: Verify inode mode when loading from disk Tetsuo Handa 2025-08-29 13:16 ` Tetsuo Handa 2025-09-12 14:18 ` [PATCH (REPOST)] " Tetsuo Handa 2025-09-12 15:05 ` Darrick J. Wong 2025-09-17 18:21 ` Dave Kleikamp
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox