Skip to content

Commit 0d04335

Browse files
committed
ext4: fix fortify warning in fs/ext4/fast_commit.c:1551
With the new fortify string system, rework the memcpy to avoid this warning: memcpy: detected field-spanning write (size 60) of single field "&raw_inode->i_generation" at fs/ext4/fast_commit.c:1551 (size 4) Cc: [email protected] Fixes: 54d9469 ("fortify: Add run-time WARN for cross-field memcpy()") Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 9f2a1d9 commit 0d04335

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/ext4/fast_commit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
15211521
struct ext4_iloc iloc;
15221522
int inode_len, ino, ret, tag = tl->fc_tag;
15231523
struct ext4_extent_header *eh;
1524+
size_t off_gen = offsetof(struct ext4_inode, i_generation);
15241525

15251526
memcpy(&fc_inode, val, sizeof(fc_inode));
15261527

@@ -1548,8 +1549,8 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
15481549
raw_inode = ext4_raw_inode(&iloc);
15491550

15501551
memcpy(raw_inode, raw_fc_inode, offsetof(struct ext4_inode, i_block));
1551-
memcpy(&raw_inode->i_generation, &raw_fc_inode->i_generation,
1552-
inode_len - offsetof(struct ext4_inode, i_generation));
1552+
memcpy((u8 *)raw_inode + off_gen, (u8 *)raw_fc_inode + off_gen,
1553+
inode_len - off_gen);
15531554
if (le32_to_cpu(raw_inode->i_flags) & EXT4_EXTENTS_FL) {
15541555
eh = (struct ext4_extent_header *)(&raw_inode->i_block[0]);
15551556
if (eh->eh_magic != EXT4_EXT_MAGIC) {

0 commit comments

Comments
 (0)