summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schoenebeck <qemu_oss@crudebyte.com>2026-05-29 18:29:26 +0200
committerMichael Tokarev <mjt@tls.msk.ru>2026-06-19 08:47:15 +0300
commit13fb03237629a595f6a8ea9c5c1d99f605c948c3 (patch)
treeaed1cad4a13f8de1967f6c67fc2834ce8abea942
parent1f6b545bf29dafecedd7647e0a90474b49f35730 (diff)
downloadqemu-13fb03237629a595f6a8ea9c5c1d99f605c948c3.tar.gz
qemu-13fb03237629a595f6a8ea9c5c1d99f605c948c3.zip
hw/9pfs: fix abort due to illegal name with Twstat rename
The legacy Twstat 9p request can be used to rename files and directories. Unlike the other, more recent rename requests like Trename and Trenameat, Twstat does not validate the submitted new name before passing it to v9fs_complete_rename(). A priviliged guest user with direct communication access to 9p server could pass a string containing '/' as new name, which causes an assertion fault (DoS) in local_name_to_path(). Fix this by rejecting such strings by checking the client supplied new name with name_is_illegal(), similar to how Trename and Trenameat handlers do already. Reported-by: Feifan Qian <bea1e@proton.me> Fixes: 8cf89e007a ("virtio-9p: Add P9_TWSTAT support") Link: https://lore.kernel.org/qemu-devel/ba09716828e82992f9d8cac7f00eee0bc1c43c61.1780072238.git.qemu_oss@crudebyte.com Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> (cherry picked from commit 7f5445e7e4050cc117ed4b137bb7dd1474e49d57) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--hw/9pfs/9p.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 0c162614f8..7c65d4f7d1 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -3638,6 +3638,11 @@ static void coroutine_fn v9fs_wstat(void *opaque)
err = -EOPNOTSUPP;
goto out;
}
+ if (name_is_illegal(v9stat.name.data)) {
+ err = -ENOENT;
+ goto out;
+ }
+
v9fs_path_write_lock(s);
err = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);
v9fs_path_unlock(s);