Skip to content

Commit be27cd6

Browse files
keestytso
authored andcommitted
ext4: use memtostr_pad() for s_volume_name
As with the other strings in struct ext4_super_block, s_volume_name is not NUL terminated. The other strings were marked in commit 072ebb3 ("ext4: add nonstring annotations to ext4.h"). Using strscpy() isn't the right replacement for strncpy(); it should use memtostr_pad() instead. Reported-by: [email protected] Closes: https://lore.kernel.org/all/[email protected]/ Fixes: 744a563 ("ext4: replace deprecated strncpy with alternatives") Signed-off-by: Kees Cook <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 7c73ddb commit be27cd6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/ext4/ext4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ struct ext4_super_block {
13471347
/*60*/ __le32 s_feature_incompat; /* incompatible feature set */
13481348
__le32 s_feature_ro_compat; /* readonly-compatible feature set */
13491349
/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
1350-
/*78*/ char s_volume_name[EXT4_LABEL_MAX]; /* volume name */
1350+
/*78*/ char s_volume_name[EXT4_LABEL_MAX] __nonstring; /* volume name */
13511351
/*88*/ char s_last_mounted[64] __nonstring; /* directory where last mounted */
13521352
/*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
13531353
/*

fs/ext4/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ static int ext4_ioctl_getlabel(struct ext4_sb_info *sbi, char __user *user_label
11511151
BUILD_BUG_ON(EXT4_LABEL_MAX >= FSLABEL_MAX);
11521152

11531153
lock_buffer(sbi->s_sbh);
1154-
strscpy_pad(label, sbi->s_es->s_volume_name);
1154+
memtostr_pad(label, sbi->s_es->s_volume_name);
11551155
unlock_buffer(sbi->s_sbh);
11561156

11571157
if (copy_to_user(user_label, label, sizeof(label)))

0 commit comments

Comments
 (0)