Skip to contentSkip to conversation

vboxsf: validate directory entry name length

PATCH New Michael Bommarito 1 participant 1 message Jul 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vboxsf: validate directory entry name length

Shared-folder dir entries carry host-reported size and length fields. vboxsf_dir_emit() checks that name.size fits in the returned buffer, but later passes name.length to vboxsf_nlscpy() or dir_emit() unchecked, so malformed host data can make the guest read past the shfl_string buffer.

Reject entries whose name.length exceeds name.size before either consumer.

Fixes 0fd169576648 ("fs: Add VirtualBox guest shared folder (vboxsf) support")
Assisted-by Claude:claude-fable-5
Assisted-by Claude:claude-opus-4-8
---
 fs/vboxsf/dir.c | 2 ++
 1 file changed, 2 insertions(+)
fs/vboxsf/dir.c +2 -0
index 42bedc4ec7af7..702d243169936 100644
@@ -129,6 +129,8 @@ static bool vboxsf_dir_emit(struct file *dir, struct dir_context *ctx)
 		end = &info->name.string.utf8[info->name.size];
 		if (WARN_ON(end > (b->buf + b->used)))
 			return false;
+		if (info->name.length > info->name.size)
+			return false;
 
 		/* Info now points to the right entry, emit it. */
 		d_type = vboxsf_get_d_type(info->info.attr.mode);
Signature · 1 line
2.53.0