ext4: Use memtostr_pad() for s_volume_name
PATCH 1/1 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 072ebb3bffe6 ("ext4: add nonstring annotations to ext4.h"). Using strscpy() isn't the right replacement for strncpy(); it should use memtostr_pad() instead.
---
Cc: "Theodore Ts'o" <[email protected]>
Cc: Justin Stitt <[email protected]>
Cc: Andreas Dilger <[email protected]>
Cc: [email protected]
--- fs/ext4/ext4.h | 2 +- fs/ext4/ioctl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +1 -1
@@ -1347,7 +1347,7 @@ struct ext4_super_block {/*60*/ __le32 s_feature_incompat;/* incompatible feature set */ __le32 s_feature_ro_compat;/* readonly-compatible feature set */ /*68*/ __u8 s_uuid[16 ];/* 128-bit uuid for volume */ -/*78*/ char s_volume_name[EXT4_LABEL_MAX ];/* volume name */ +/*78*/ char s_volume_name[EXT4_LABEL_MAX] __nonstring; /* volume name */ /*88*/ char s_last_mounted[64] __nonstring; /* directory where last mounted *//*C8*/ __le32 s_algorithm_usage_bitmap;/* For compression */ /*
fs/ext4/ioctl.c +1 -1
@@ -1151,7 +1151,7 @@ static int ext4_ioctl_getlabel(struct ext4_sb_info *sbi, char __user *user_labelBUILD_BUG_ON (EXT4_LABEL_MAX >=FSLABEL_MAX );lock_buffer (sbi->s_sbh); -strscpy_pad (label, sbi->s_es->s_volume_name); +memtostr_pad (label, sbi->s_es->s_volume_name);unlock_buffer (sbi->s_sbh);if (copy_to_user (user_label, label,sizeof (label)))
Signature · 1 line
2.34.1
Quoted 8 lines · Kees Cook
As with the other strings in struct
ext4_super_block,s_volume_nameis not NUL terminated. The other strings were marked in commit072ebb3bffe6("ext4: add nonstring annotations toext4.h"). Usingstrscpy()isn't the right replacement forstrncpy(); it should usememtostr_pad()instead.[...]
Applied, thanks!
[1/1] ext4: Use memtostr_pad() for s_volume_name
commit: be27cd64461c45a6088a91a04eba5cd44e1767ef
Best regards,
Signature · 1 line
Theodore Ts'o <[email protected]>