nilfs2: prevent out-of-bounds read in super root block parsing
Ryusuke Konishi
maintainerPATCH 1/1 nilfs2: prevent out-of-bounds read in super root block parsing
From: David Lee <[email protected]>
super-root inode metadata size is trusted before nilfs_read_inode_common().
Reject super-root inode sizes whose computed on-disk footprint exceeds the filesystem block size. This prevents malformed filesystem images from making nilfs_read_inode_common() read past the end of the super-root block.
[ryusuke: clarify the commit title]
---
Hi Viacheslav,
please apply this for the next cycle.
As described, this prevents out-of-bounds memory access that could occur with a tampered file system image.
Thanks,
Ryusuke Konishi
fs/nilfs2/the_nilfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/nilfs2/the_nilfs.c +6 -0
@@ -461,6 +461,12 @@ static int nilfs_store_disk_layout(struct the_nilfs *nilfs, nilfs->ns_inode_size);return -EINVAL ; } +if (NILFS_SR_BYTES (nilfs->ns_inode_size) > nilfs->ns_blocksize) { +nilfs_err (nilfs->ns_sb, +"too large inode size for super root: %d bytes" , + nilfs->ns_inode_size); +return -EINVAL ; + } nilfs->ns_first_ino =le32_to_cpu (sbp->s_first_ino);if (nilfs->ns_first_ino <NILFS_USER_INO ) {
Signature · 1 line
2.43.0
Quoted 48 lines · Ryusuke Konishi
From: David Lee <[email protected]>
super-root inode metadata size is trusted before
nilfs_read_inode_common().Reject super-root inode sizes whose computed on-disk footprint exceeds the
filesystem block size. This prevents malformed filesystem images from makingnilfs_read_inode_common()read past the end of the super-root block.[ryusuke: clarify the commit title]
Fixes 8a9d2191e9f4 ("nilfs2: operations for the_nilfs core object")Signed-off-by David Lee <[email protected]>Assisted-by Codex:gpt-5.5Signed-off-by Ryusuke Konishi <[email protected]>---
Hi Viacheslav,please apply this for the next cycle.
As described, this prevents out-of-bounds memory access that could occur with a tampered file system image.
Thanks,
Ryusuke Konishifs/nilfs2/the_nilfs.c | 6 ++++++
1 file changed, 6 insertions(+)fs/nilfs2/the_nilfs.c +6
-0@@ -461,6 +461,12 @@ static int nilfs_store_disk_layout(structthe_nilfs *nilfs, nilfs->ns_inode_size); return -EINVAL; } + if (NILFS_SR_BYTES(nilfs->ns_inode_size) > nilfs- >ns_blocksize) { +nilfs_err (nilfs->ns_sb, + "too large inode size for super root: %d bytes", + nilfs->ns_inode_size); +return -EINVAL ; + }
Quoted 3 lines
nilfs->ns_first_ino=le32_to_cpu(sbp->s_first_ino); if (nilfs->ns_first_ino<NILFS_USER_INO) {
Applied.
Thanks,
Slava.