hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/gfs2/glops.c
....@@ -405,6 +405,7 @@
405405
406406 static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
407407 {
408
+ struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
408409 const struct gfs2_dinode *str = buf;
409410 struct timespec64 atime;
410411 u16 height, depth;
....@@ -444,7 +445,7 @@
444445 /* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */
445446 gfs2_set_inode_flags(&ip->i_inode);
446447 height = be16_to_cpu(str->di_height);
447
- if (unlikely(height > GFS2_MAX_META_HEIGHT))
448
+ if (unlikely(height > sdp->sd_max_height))
448449 goto corrupt;
449450 ip->i_height = (u8)height;
450451
....@@ -454,6 +455,9 @@
454455 ip->i_depth = (u8)depth;
455456 ip->i_entries = be32_to_cpu(str->di_entries);
456457
458
+ if (gfs2_is_stuffed(ip) && ip->i_inode.i_size > gfs2_max_stuffed_size(ip))
459
+ goto corrupt;
460
+
457461 if (S_ISREG(ip->i_inode.i_mode))
458462 gfs2_set_aops(&ip->i_inode);
459463