Skip to content

Commit 928a87e

Browse files
committed
Merge tag 'gfs2-v6.8-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 fix from Andreas Gruenbacher: - Fix boundary check in punch_hole * tag 'gfs2-v6.8-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: gfs2: Fix invalid metadata access in punch_hole
2 parents 174fdc9 + c95346a commit 928a87e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/gfs2/bmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,8 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
17181718
struct buffer_head *dibh, *bh;
17191719
struct gfs2_holder rd_gh;
17201720
unsigned int bsize_shift = sdp->sd_sb.sb_bsize_shift;
1721-
u64 lblock = (offset + (1 << bsize_shift) - 1) >> bsize_shift;
1721+
unsigned int bsize = 1 << bsize_shift;
1722+
u64 lblock = (offset + bsize - 1) >> bsize_shift;
17221723
__u16 start_list[GFS2_MAX_META_HEIGHT];
17231724
__u16 __end_list[GFS2_MAX_META_HEIGHT], *end_list = NULL;
17241725
unsigned int start_aligned, end_aligned;
@@ -1729,7 +1730,7 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
17291730
u64 prev_bnr = 0;
17301731
__be64 *start, *end;
17311732

1732-
if (offset >= maxsize) {
1733+
if (offset + bsize - 1 >= maxsize) {
17331734
/*
17341735
* The starting point lies beyond the allocated metadata;
17351736
* there are no blocks to deallocate.

0 commit comments

Comments
 (0)