Skip to content

Commit 46194b5

Browse files
zhanxusheng1024-osgregkh
authored andcommitted
erofs: include the trailing NUL in FS_IOC_GETFSLABEL
[ Upstream commit d6250d4 ] erofs_ioctl_get_volume_label() passes strlen(sbi->volume_name) as the length to copy_to_user(), which copies the label string without the trailing NUL byte. Since FS_IOC_GETFSLABEL callers expect a NUL-terminated string in the FSLABEL_MAX-sized buffer and may not pre-zero the buffer, this can cause userspace to read past the label into uninitialised stack memory. Fix this by using strlen() + 1 to include the NUL terminator, consistent with how ext4 and xfs implement FS_IOC_GETFSLABEL. Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com> Fixes: 1cf12c7 ("erofs: Add support for FS_IOC_GETFSLABEL") Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Chunhai Guo <guochunhai@vivo.com> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5263ed3 commit 46194b5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/erofs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static int erofs_ioctl_get_volume_label(struct inode *inode, void __user *arg)
348348
ret = clear_user(arg, 1);
349349
else
350350
ret = copy_to_user(arg, sbi->volume_name,
351-
strlen(sbi->volume_name));
351+
strlen(sbi->volume_name) + 1);
352352
return ret ? -EFAULT : 0;
353353
}
354354

0 commit comments

Comments
 (0)