]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bfs: Reconstruct file type when loading from disk
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Thu, 23 Oct 2025 13:25:49 +0000 (22:25 +0900)
committerChristian Brauner <brauner@kernel.org>
Wed, 29 Oct 2025 13:39:34 +0000 (14:39 +0100)
commit34ab4c75588c07cca12884f2bf6b0347c7a13872
treea455c650e2cab7a5f2d053f3ff6f08b474ccc59d
parent330e2c514823008b22e6afd2055715bc46dd8d55
bfs: Reconstruct file type when loading from disk

syzbot is reporting that S_IFMT bits of inode->i_mode can become bogus when
the S_IFMT bits of the 32bits "mode" field loaded from disk are corrupted
or when the 32bits "attributes" field loaded from disk are corrupted.

A documentation says that BFS uses only lower 9 bits of the "mode" field.
But I can't find an explicit explanation that the unused upper 23 bits
(especially, the S_IFMT bits) are initialized with 0.

Therefore, ignore the S_IFMT bits of the "mode" field loaded from disk.
Also, verify that the value of the "attributes" field loaded from disk is
either BFS_VREG or BFS_VDIR (because BFS supports only regular files and
the root directory).

Reported-by: 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>
Link: https://patch.msgid.link/fabce673-d5b9-4038-8287-0fd65d80203b@I-love.SAKURA.ne.jp
Reviewed-by: Tigran Aivazian <aivazian.tigran@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/bfs/inode.c