Re: [syzbot] [hfs?] KMSAN: uninit-value in copy_name

From: Edward Adam Davis
Date: Mon May 20 2024 - 20:49:01 EST


please test uiv in copy_name

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a5131c3fdf26

diff --git a/fs/hfsplus/unicode.c b/fs/hfsplus/unicode.c
index 73342c925a4b..8e97df12375d 100644
--- a/fs/hfsplus/unicode.c
+++ b/fs/hfsplus/unicode.c
@@ -234,6 +234,7 @@ int hfsplus_uni2asc(struct super_block *sb,
}
done:
res = nls->uni2char(cc, op, len);
+ printk("res: %d, cc: %d, op:%p, len: %d, ustrlen: %d, %s\n", res, cc, op, len, ustrlen, __func__);
if (res < 0) {
if (res == -ENAMETOOLONG)
goto out;
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index 9c9ff6b8c6f7..a02903a929a6 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -733,14 +733,16 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size)
goto end_listxattr;

xattr_name_len = NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN;
+ printk("1sb: %p, xnl: %d, %s\n", strbuf, xattr_name_len, __func__);
if (hfsplus_uni2asc(inode->i_sb,
(const struct hfsplus_unistr *)&fd.key->attr.key_name,
- strbuf, &xattr_name_len)) {
+ strbuf, &xattr_name_len) || !xattr_name_len) {
pr_err("unicode conversion failed\n");
res = -EIO;
goto end_listxattr;
}

+ printk("3s:%d, buf:%p, res:%d, sb: %s, xnl: %d, %s\n", size, buffer, res, strbuf, xattr_name_len, __func__);
if (!buffer || !size) {
if (can_list(strbuf))
res += name_len(strbuf, xattr_name_len);