Skip to content

Commit 24ccea7

Browse files
committed
Merge tag 'xfs-4.20-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Darrick Wong: - fix incorrect dropping of error code from bmap - print buffer offsets instead of useless hashed pointers when dumping corrupt metadata - fix integer overflow in attribute verifier * tag 'xfs-4.20-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: fix overflow in xfs_attr3_leaf_verify xfs: print buffer offsets when dumping corrupt buffers xfs: Fix error code in 'xfs_ioc_getbmap()'
2 parents 6a1ac56 + 837514f commit 24ccea7

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ xfs_attr3_leaf_verify(
243243
struct xfs_mount *mp = bp->b_target->bt_mount;
244244
struct xfs_attr_leafblock *leaf = bp->b_addr;
245245
struct xfs_attr_leaf_entry *entries;
246-
uint16_t end;
246+
uint32_t end; /* must be 32bit - see below */
247247
int i;
248248

249249
xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &ichdr, leaf);
@@ -293,6 +293,11 @@ xfs_attr3_leaf_verify(
293293
/*
294294
* Quickly check the freemap information. Attribute data has to be
295295
* aligned to 4-byte boundaries, and likewise for the free space.
296+
*
297+
* Note that for 64k block size filesystems, the freemap entries cannot
298+
* overflow as they are only be16 fields. However, when checking end
299+
* pointer of the freemap, we have to be careful to detect overflows and
300+
* so use uint32_t for those checks.
296301
*/
297302
for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) {
298303
if (ichdr.freemap[i].base > mp->m_attr_geo->blksize)
@@ -303,7 +308,9 @@ xfs_attr3_leaf_verify(
303308
return __this_address;
304309
if (ichdr.freemap[i].size & 0x3)
305310
return __this_address;
306-
end = ichdr.freemap[i].base + ichdr.freemap[i].size;
311+
312+
/* be care of 16 bit overflows here */
313+
end = (uint32_t)ichdr.freemap[i].base + ichdr.freemap[i].size;
307314
if (end < ichdr.freemap[i].base)
308315
return __this_address;
309316
if (end > mp->m_attr_geo->blksize)

fs/xfs/xfs_ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ xfs_ioc_getbmap(
16081608
error = 0;
16091609
out_free_buf:
16101610
kmem_free(buf);
1611-
return 0;
1611+
return error;
16121612
}
16131613

16141614
struct getfsmap_info {

fs/xfs/xfs_message.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ assfail(char *expr, char *file, int line)
107107
void
108108
xfs_hex_dump(void *p, int length)
109109
{
110-
print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1);
110+
print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
111111
}

0 commit comments

Comments
 (0)