Skip to content

Commit 293f7e0

Browse files
lizf-osChris Mason
authored andcommitted
Btrfs: zero unused bytes in inode item
The otime field is not zeroed, so users will see random otime in an old filesystem with a new kernel which has otime support in the future. The reserved bytes are also not zeroed, and we'll have compatibility issue if we make use of those bytes. Signed-off-by: Li Zefan <lizefan@huawei.com>
1 parent b4d7c3c commit 293f7e0

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎fs/btrfs/delayed-inode.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static inline void btrfs_init_delayed_node(
6262
INIT_LIST_HEAD(&delayed_node->n_list);
6363
INIT_LIST_HEAD(&delayed_node->p_list);
6464
delayed_node->bytes_reserved = 0;
65+
memset(&delayed_node->inode_item, 0, sizeof(delayed_node->inode_item));
6566
}
6667

6768
static inline int btrfs_is_continuous_delayed_item(

‎fs/btrfs/inode.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4693,6 +4693,8 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
46934693
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
46944694
inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
46954695
struct btrfs_inode_item);
4696+
memset_extent_buffer(path->nodes[0], 0, (unsigned long)inode_item,
4697+
sizeof(*inode_item));
46964698
fill_inode_item(trans, path->nodes[0], inode_item, inode);
46974699

46984700
ref = btrfs_item_ptr(path->nodes[0], path->slots[0] + 1,

0 commit comments

Comments
 (0)