Skip to content

Commit cfcdb5b

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fix inode height consistency check
The maximum allowed height of an inode's metadata tree depends on the filesystem block size; it is lower for bigger-block filesystems. When reading in an inode, make sure that the height doesn't exceed the maximum allowed height. Arrays like sd_heightsize are sized to be big enough for any filesystem block size; they will often be slightly bigger than what's needed for a specific filesystem. Reported-by: [email protected] Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 14a5851 commit cfcdb5b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/gfs2/glops.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ static int inode_go_demote_ok(const struct gfs2_glock *gl)
396396

397397
static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
398398
{
399+
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
399400
const struct gfs2_dinode *str = buf;
400401
struct timespec64 atime;
401402
u16 height, depth;
@@ -442,7 +443,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
442443
/* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */
443444
gfs2_set_inode_flags(inode);
444445
height = be16_to_cpu(str->di_height);
445-
if (unlikely(height > GFS2_MAX_META_HEIGHT))
446+
if (unlikely(height > sdp->sd_max_height))
446447
goto corrupt;
447448
ip->i_height = (u8)height;
448449

0 commit comments

Comments
 (0)