[PATCH] exfat: fix truncated volume labels returned by FS_IOC_GETFSLABEL

Yang Wen posted 1 patch 1 month, 2 weeks ago
fs/exfat/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] exfat: fix truncated volume labels returned by FS_IOC_GETFSLABEL
Posted by Yang Wen 1 month, 2 weeks ago
exfat_ioctl_get_volume_label() passes uniname.name_len to
exfat_utf16_to_nls() as the output buffer length. However, name_len is
the number of UTF-16 code units, while exfat_utf16_to_nls() expects the
buffer size in bytes.

As a result, volume labels that expand during charset conversion are
truncated.The destination buffer is FSLABEL_MAX bytes long, so pass
its actual size to the conversion helper.

Signed-off-by: Yang Wen <anmuxixixi@gmail.com>
---
 fs/exfat/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 5e9b47ecc614..1c1524caaaf7 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -566,7 +566,7 @@ static int exfat_ioctl_get_volume_label(struct super_block *sb, unsigned long ar
 	if (ret < 0)
 		return ret;
 
-	ret = exfat_utf16_to_nls(sb, &uniname, label, uniname.name_len);
+	ret = exfat_utf16_to_nls(sb, &uniname, label, sizeof(label));
 	if (ret < 0)
 		return ret;
 
-- 
2.34.1
Re: [PATCH] exfat: fix truncated volume labels returned by FS_IOC_GETFSLABEL
Posted by Namjae Jeon 1 month, 2 weeks ago
On Mon, Aug 10, 2026 at 11:58 PM Yang Wen <anmuxixixi@gmail.com> wrote:
>
> exfat_ioctl_get_volume_label() passes uniname.name_len to
> exfat_utf16_to_nls() as the output buffer length. However, name_len is
> the number of UTF-16 code units, while exfat_utf16_to_nls() expects the
> buffer size in bytes.
>
> As a result, volume labels that expand during charset conversion are
> truncated.The destination buffer is FSLABEL_MAX bytes long, so pass
> its actual size to the conversion helper.
>
> Signed-off-by: Yang Wen <anmuxixixi@gmail.com>
Applied it to #dev.
Thanks!