Skip to content

9pfs: fix fstat() after unlink() (with a Linux guest)

Christian Schoenebeck qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6tests/9p: add 'use-after-unlink' testtests/qtest/virtio-9p-test.c+41 -02 replies
2/6tests/9p: fix Rreaddir response nametests/qtest/libqos/virtio-9p-client.c+1 -12 replies
3/6tests/9p: add missing Rgetattr response nametests/qtest/libqos/virtio-9p-client.c+1 -02 replies
4/69pfs: remove obsolete comment in v9fs_getattr()hw/9pfs/9p.c+0 -42 replies
5/69pfs: fix 'Tgetattr' after unlinkhw/9pfs/9p.c+7 -13 replies
6/6tests/9p: also check 'Tgetattr' in 'use-after-unlink' testtests/qtest/virtio-9p-test.c+5 -01 reply

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchGreg Kurz
1/6R-b
2/6R-b
3/6R-b
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/6] 9pfs: fix fstat() after unlink() (with a Linux guest)

This fixes an infamous, long standing bug:
https://gitlab.com/qemu-project/qemu/-/issues/103

* Actual fix of this bug is patch 5.

* Patches 1 and 6 add a test case to verify the expected behaviour.

* The other patches (2, 3, 4) are basically just minor cleanup patches more or less (un)related that I simply did not bother to send separately.

Probably there are still other 9p request types that should be fixed for this use-after-unlink idiom, but this series fixes the mentioned bug report as described by reporter, so fair enough to round this up here for now.

Simple test app to verify this behaviour on a Linux guest:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

int main() {
struct stat st;
int fd = open("doa-file", O_RDWR | O_CREAT | O_EXCL, 0600); unlink("doa-file");
int res = fstat(fd, &st);
printf("fstat() = %d\n", res);
return res;
}

Christian Schoenebeck (6):
tests/9p: add 'use-after-unlink' test
tests/9p: fix Rreaddir response name
tests/9p: add missing Rgetattr response name 9pfs: remove obsolete comment in v9fs_getattr() 9pfs: fix 'Tgetattr' after unlink
tests/9p: also check 'Tgetattr' in 'use-after-unlink' test

 hw/9pfs/9p.c                          | 12 ++++---
 tests/qtest/libqos/virtio-9p-client.c |  3 +-
 tests/qtest/virtio-9p-test.c          | 46 +++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 6 deletions(-)
Signature · 1 line
2.39.5