Skip to content

Commit c746c3b

Browse files
committed
Merge tag 'for-6.18-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: "Two short fixes that would be good to have before rc1" * tag 'for-6.18-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: fix PAGE_SIZE format specifier in open_ctree() btrfs: avoid potential out-of-bounds in btrfs_encode_fh()
2 parents 81538c8 + 4335c44 commit c746c3b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
33973397

33983398
if (fs_info->sectorsize > PAGE_SIZE)
33993399
btrfs_warn(fs_info,
3400-
"support for block size %u with page size %zu is experimental, some features may be missing",
3400+
"support for block size %u with page size %lu is experimental, some features may be missing",
34013401
fs_info->sectorsize, PAGE_SIZE);
34023402
/*
34033403
* Handle the space caching options appropriately now that we have the

fs/btrfs/export.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
2323
int type;
2424

2525
if (parent && (len < BTRFS_FID_SIZE_CONNECTABLE)) {
26-
*max_len = BTRFS_FID_SIZE_CONNECTABLE;
26+
if (btrfs_root_id(BTRFS_I(inode)->root) !=
27+
btrfs_root_id(BTRFS_I(parent)->root))
28+
*max_len = BTRFS_FID_SIZE_CONNECTABLE_ROOT;
29+
else
30+
*max_len = BTRFS_FID_SIZE_CONNECTABLE;
2731
return FILEID_INVALID;
2832
} else if (len < BTRFS_FID_SIZE_NON_CONNECTABLE) {
2933
*max_len = BTRFS_FID_SIZE_NON_CONNECTABLE;
@@ -45,6 +49,8 @@ static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len,
4549
parent_root_id = btrfs_root_id(BTRFS_I(parent)->root);
4650

4751
if (parent_root_id != fid->root_objectid) {
52+
if (*max_len < BTRFS_FID_SIZE_CONNECTABLE_ROOT)
53+
return FILEID_INVALID;
4854
fid->parent_root_objectid = parent_root_id;
4955
len = BTRFS_FID_SIZE_CONNECTABLE_ROOT;
5056
type = FILEID_BTRFS_WITH_PARENT_ROOT;

0 commit comments

Comments
 (0)