mirror of https://github.com/xemu-project/xemu.git
* Fix open-unlink-fstat idiom on Linux guests.
* Add test to verify this behaviour. * Cleanup patches. -----BEGIN PGP SIGNATURE----- iQJLBAABCgA1FiEEltjREM96+AhPiFkBNMK1h2Wkc5UFAmdIvDkXHHFlbXVfb3Nz QGNydWRlYnl0ZS5jb20ACgkQNMK1h2Wkc5X8ixAApDPStDxYf1CGdLirInHGp77i 0MlBsuaP00f8bZyCLJCFgax2+ogXD72Ptw2thDDMtkMsg9lqZwOtG5I4cJGC3TK2 J4ZXpg/mg0bY+4o2gvnyeKv8BFl5wE91pdIeFX8ufQ+L2WE+fasWOn38TFB/T/8Z 1naN4A8Mu5F9myJ+F6pIYlJfkgbZniNib9BgSMG8pYI6uayWD+YVjR139ozWCf1c vhFFpLrwW4j3DOC0WblghQmiMwhXo1QxNAEq0x31/eoD1+calJAwhWsLWksuVIqR 6wbGPfNVozgk9l7owYB5Gams5zVJRfLD5LCAitUx2qqMMzxuD3QldLjOmFA/8XdG +2/ROBeXJ51blCAMFdp9IwTKzimvuWVL3kXbcQ3n+D459iBZzqW+9w4EYVYShpp6 uwAAkW9fwVR/U7ERG3n8D6Cw1B9Scvtjksw/VCe9XUNFp6H66K/OXy8NFmnZZk9K K9SYkKOVixwZDqMoGoLsoxx0DbakYL+lBYrl6qVZUPRLOjJ+JvLAoblJ0ZmUgsl2 lXG7vO96+LyRvVjqPoi2D7+MHrmFoeRgWjzZqFqWOakXBHCKcCEVzpAoB4eYyQrj rXC5BNhdu9yIa7Dy7V6tFoXPdN1is90bJs92DYTsOG1KdU2DviAUSZk4MjTJzQWN 3fvOcZPFq74228CWrN4= =XP1U -----END PGP SIGNATURE----- Merge tag 'pull-9p-20241128' of https://github.com/cschoenebeck/qemu into staging * Fix open-unlink-fstat idiom on Linux guests. * Add test to verify this behaviour. * Cleanup patches. # -----BEGIN PGP SIGNATURE----- # # iQJLBAABCgA1FiEEltjREM96+AhPiFkBNMK1h2Wkc5UFAmdIvDkXHHFlbXVfb3Nz # QGNydWRlYnl0ZS5jb20ACgkQNMK1h2Wkc5X8ixAApDPStDxYf1CGdLirInHGp77i # 0MlBsuaP00f8bZyCLJCFgax2+ogXD72Ptw2thDDMtkMsg9lqZwOtG5I4cJGC3TK2 # J4ZXpg/mg0bY+4o2gvnyeKv8BFl5wE91pdIeFX8ufQ+L2WE+fasWOn38TFB/T/8Z # 1naN4A8Mu5F9myJ+F6pIYlJfkgbZniNib9BgSMG8pYI6uayWD+YVjR139ozWCf1c # vhFFpLrwW4j3DOC0WblghQmiMwhXo1QxNAEq0x31/eoD1+calJAwhWsLWksuVIqR # 6wbGPfNVozgk9l7owYB5Gams5zVJRfLD5LCAitUx2qqMMzxuD3QldLjOmFA/8XdG # +2/ROBeXJ51blCAMFdp9IwTKzimvuWVL3kXbcQ3n+D459iBZzqW+9w4EYVYShpp6 # uwAAkW9fwVR/U7ERG3n8D6Cw1B9Scvtjksw/VCe9XUNFp6H66K/OXy8NFmnZZk9K # K9SYkKOVixwZDqMoGoLsoxx0DbakYL+lBYrl6qVZUPRLOjJ+JvLAoblJ0ZmUgsl2 # lXG7vO96+LyRvVjqPoi2D7+MHrmFoeRgWjzZqFqWOakXBHCKcCEVzpAoB4eYyQrj # rXC5BNhdu9yIa7Dy7V6tFoXPdN1is90bJs92DYTsOG1KdU2DviAUSZk4MjTJzQWN # 3fvOcZPFq74228CWrN4= # =XP1U # -----END PGP SIGNATURE----- # gpg: Signature made Thu 28 Nov 2024 18:53:45 GMT # gpg: using RSA key 96D8D110CF7AF8084F88590134C2B58765A47395 # gpg: issuer "qemu_oss@crudebyte.com" # gpg: Good signature from "Christian Schoenebeck <qemu_oss@crudebyte.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: ECAB 1A45 4014 1413 BA38 4926 30DB 47C3 A012 D5F4 # Subkey fingerprint: 96D8 D110 CF7A F808 4F88 5901 34C2 B587 65A4 7395 * tag 'pull-9p-20241128' of https://github.com/cschoenebeck/qemu: tests/9p: also check 'Tgetattr' in 'use-after-unlink' test 9pfs: fix 'Tgetattr' after unlink 9pfs: remove obsolete comment in v9fs_getattr() tests/9p: add missing Rgetattr response name tests/9p: fix Rreaddir response name tests/9p: add 'use-after-unlink' test 9pfs: cleanup V9fsFidState Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
95ee23ed2d
12
hw/9pfs/9p.c
12
hw/9pfs/9p.c
|
@ -1596,11 +1596,13 @@ static void coroutine_fn v9fs_getattr(void *opaque)
|
|||
retval = -ENOENT;
|
||||
goto out_nofid;
|
||||
}
|
||||
/*
|
||||
* Currently we only support BASIC fields in stat, so there is no
|
||||
* need to look at request_mask.
|
||||
*/
|
||||
retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
|
||||
if ((fidp->fid_type == P9_FID_FILE && fidp->fs.fd != -1) ||
|
||||
(fidp->fid_type == P9_FID_DIR && fidp->fs.dir.stream))
|
||||
{
|
||||
retval = v9fs_co_fstat(pdu, fidp, &stbuf);
|
||||
} else {
|
||||
retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
|
||||
}
|
||||
if (retval < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -280,7 +280,6 @@ struct V9fsFidState {
|
|||
uid_t uid;
|
||||
int ref;
|
||||
bool clunked;
|
||||
QSIMPLEQ_ENTRY(V9fsFidState) next;
|
||||
QSLIST_ENTRY(V9fsFidState) reclaim_next;
|
||||
};
|
||||
|
||||
|
|
|
@ -235,10 +235,11 @@ static const char *rmessage_name(uint8_t id)
|
|||
id == P9_RMKDIR ? "RMKDIR" :
|
||||
id == P9_RLCREATE ? "RLCREATE" :
|
||||
id == P9_RSYMLINK ? "RSYMLINK" :
|
||||
id == P9_RGETATTR ? "RGETATTR" :
|
||||
id == P9_RLINK ? "RLINK" :
|
||||
id == P9_RUNLINKAT ? "RUNLINKAT" :
|
||||
id == P9_RFLUSH ? "RFLUSH" :
|
||||
id == P9_RREADDIR ? "READDIR" :
|
||||
id == P9_RREADDIR ? "RREADDIR" :
|
||||
"<unknown>";
|
||||
}
|
||||
|
||||
|
|
|
@ -693,6 +693,50 @@ static void fs_unlinkat_hardlink(void *obj, void *data,
|
|||
g_assert(stat(real_file, &st_real) == 0);
|
||||
}
|
||||
|
||||
static void fs_use_after_unlink(void *obj, void *data,
|
||||
QGuestAllocator *t_alloc)
|
||||
{
|
||||
QVirtio9P *v9p = obj;
|
||||
v9fs_set_allocator(t_alloc);
|
||||
static const uint32_t write_count = P9_MAX_SIZE / 2;
|
||||
g_autofree char *real_file = virtio_9p_test_path("09/doa_file");
|
||||
g_autofree char *buf = g_malloc0(write_count);
|
||||
struct stat st_file;
|
||||
struct v9fs_attr attr;
|
||||
uint32_t fid_file;
|
||||
uint32_t count;
|
||||
|
||||
tattach({ .client = v9p });
|
||||
|
||||
/* create a file "09/doa_file" and make sure it exists and is regular */
|
||||
tmkdir({ .client = v9p, .atPath = "/", .name = "09" });
|
||||
tlcreate({ .client = v9p, .atPath = "09", .name = "doa_file" });
|
||||
g_assert(stat(real_file, &st_file) == 0);
|
||||
g_assert((st_file.st_mode & S_IFMT) == S_IFREG);
|
||||
|
||||
/* request a FID for that regular file that we can work with next */
|
||||
fid_file = twalk({
|
||||
.client = v9p, .fid = 0, .path = "09/doa_file"
|
||||
}).newfid;
|
||||
g_assert(fid_file != 0);
|
||||
|
||||
/* now first open the file in write mode before ... */
|
||||
tlopen({ .client = v9p, .fid = fid_file, .flags = O_WRONLY });
|
||||
/* ... removing the file from file system */
|
||||
tunlinkat({ .client = v9p, .atPath = "09", .name = "doa_file" });
|
||||
|
||||
/* file is removed, but we still have it open, so this should succeed */
|
||||
tgetattr({
|
||||
.client = v9p, .fid = fid_file, .request_mask = P9_GETATTR_BASIC,
|
||||
.rgetattr.attr = &attr
|
||||
});
|
||||
count = twrite({
|
||||
.client = v9p, .fid = fid_file, .offset = 0, .count = write_count,
|
||||
.data = buf
|
||||
}).count;
|
||||
g_assert_cmpint(count, ==, write_count);
|
||||
}
|
||||
|
||||
static void cleanup_9p_local_driver(void *data)
|
||||
{
|
||||
/* remove previously created test dir when test is completed */
|
||||
|
@ -758,6 +802,8 @@ static void register_virtio_9p_test(void)
|
|||
qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &opts);
|
||||
qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardlink,
|
||||
&opts);
|
||||
qos_add_test("local/use_after_unlink", "virtio-9p", fs_use_after_unlink,
|
||||
&opts);
|
||||
}
|
||||
|
||||
libqos_init(register_virtio_9p_test);
|
||||
|
|
Loading…
Reference in New Issue