Re: [PATCH] bfs: Verify inode mode when loading from disk

From: Tigran Aivazian
Date: Fri Oct 10 2025 - 11:46:47 EST


On Fri, 10 Oct 2025 at 15:24, Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
>
> The inode mode loaded from corrupted disk can be invalid.
> Since Boot File System supports only root directory and regular files [1],
> reject inodes which are neither directory nor regular file.
>
> ...
> + if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) {
> + brelse(bh);
> + printf("Bad file type (0%04o) %s:%08lx.\n",
> + inode->i_mode, inode->i_sb->s_id, ino);
> + goto error;
> + }

Thank you, but logically this code should simply be inside the "else"
clause of the previous checks, which already check for BFS_VDIR and
BFS_VREG, I think.

--
Tigran