diff options
author | Jan Kara <jack@suse.cz> | 2023-01-03 12:03:35 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-03-11 18:39:57 +0300 |
commit | a44ec34b90440ada190924f5908b97026504fdcd (patch) | |
tree | cc9d870453f1ec79c0cb8803d47fd03384152ce0 | |
parent | 63478c3ce24bba1fb4736102bfb1aa986e215cb0 (diff) | |
download | linux-a44ec34b90440ada190924f5908b97026504fdcd.tar.xz |
udf: Detect system inodes linked into directory hierarchy
commit 85a37983ec69cc9fcd188bc37c4de15ee326355a upstream.
When UDF filesystem is corrupted, hidden system inodes can be linked
into directory hierarchy which is an avenue for further serious
corruption of the filesystem and kernel confusion as noticed by syzbot
fuzzed images. Refuse to access system inodes linked into directory
hierarchy and vice versa.
CC: stable@vger.kernel.org
Reported-by: syzbot+38695a20b8addcbc1084@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/udf/inode.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 8fed514be5f3..71acce2c0b6a 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -1897,8 +1897,13 @@ struct inode *__udf_iget(struct super_block *sb, struct kernel_lb_addr *ino, if (!inode) return ERR_PTR(-ENOMEM); - if (!(inode->i_state & I_NEW)) + if (!(inode->i_state & I_NEW)) { + if (UDF_I(inode)->i_hidden != hidden_inode) { + iput(inode); + return ERR_PTR(-EFSCORRUPTED); + } return inode; + } memcpy(&UDF_I(inode)->i_location, ino, sizeof(struct kernel_lb_addr)); err = udf_read_inode(inode, hidden_inode); |