9pfs: improve portability to older systems
PATCH 1/1 9pfs: improve portability to older systems
Small requirements on "new" features have percolated to virtio-9p-local.c. In particular, the utimensat wrapper actually only supports dirfd = AT_FDCWD and flags = AT_SYMLINK_NOFOLLOW in the fallback code. Remove the arguments so that virtio-9p-local.c will not use AT_* constants.
At the same time, fail local_ioc_getversion if the ioctl is not supported by the host.
--- hw/9pfs/virtio-9p-local.c | 7 +++++-- oslib-posix.c | 5 ++--- qemu-os-posix.h | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-)
hw/9pfs/virtio-9p-local.c +5 -2
@@ -583,8 +583,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path,char buffer[PATH_MAX ];char *path = fs_path->data; -return qemu_utimensat (AT_FDCWD ,rpath (s, path, buffer), buf, -AT_SYMLINK_NOFOLLOW ); +return qemu_utimens (rpath (s, path, buffer), buf); }static int local_remove (FsContext *ctx,const char *path)
@@ -694,6 +693,7 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) { int err; +#ifdef FS_IOC_GETVERSION V9fsFidOpenState fid_open;/*
@@ -709,6 +709,9 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, } err =ioctl (fid_open.fd,FS_IOC_GETVERSION , st_gen);local_close (ctx, &fid_open); +#else + err = -ENOTTY ; +#endif return err; }
oslib-posix.c +2 -3
@@ -162,8 +162,7 @@ int qemu_pipe(int pipefd[2])return ret; } -int qemu_utimensat (int dirfd,const char *path,const struct timespec *times, -int flags) +int qemu_utimens (const char *path,const struct timespec *times) {struct timeval tv[2 ], tv_now;struct stat st;
@@ -171,7 +170,7 @@ int qemu_utimensat(int dirfd, const char *path, const struct timespec *times,#ifdef CONFIG_UTIMENSAT int ret; - ret =utimensat (dirfd, path, times, flags); + ret =utimensat (AT_FDCWD , path, times,AT_SYMLINK_NOFOLLOW );if (ret !=-1 || errno !=ENOSYS ) {return ret; }
qemu-os-posix.h +1 -2
@@ -44,7 +44,6 @@ typedef struct timeval qemu_timeval;#endif #endif typedef struct timespec qemu_timespec ; -int qemu_utimensat (int dirfd,const char *path,const qemu_timespec *times, -int flags); +int qemu_utimens (const char *path,const qemu_timespec *times);#endif
Signature · 1 line
1.7.7.1
Quoted 20 lines · Paolo Bonzini
Small requirements on "new" features have percolated to
virtio-9p-local.c. In particular, the utimensat wrapper actually only supports dirfd =AT_FDCWDand flags =AT_SYMLINK_NOFOLLOWin the fallback code. Remove the arguments so thatvirtio-9p-local.cwill not use AT_* constants.At the same time, fail
local_ioc_getversionif the ioctl is not supported by the host.Signed-off-by Paolo Bonzini<[email protected]>--- hw/9pfs/virtio-9p-local.c | 7 +++++-- oslib-posix.c | 5 ++--- qemu-os-posix.h | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-)hw/9pfs/virtio-9p-local.c +0
-0
hw/9pfs/virtio-9p-local.c static int local_utimensat(FsContext *s, V9fsPath *fs_path, · line 586
Quoted 6 lines
hw/9pfs/virtio-9p-local.c +1
-2@@ -583,8 +583,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path,char buffer[PATH_MAX ];char *path = fs_path->data; -return qemu_utimensat (AT_FDCWD ,rpath (s, path, buffer), buf, -AT_SYMLINK_NOFOLLOW ); +return qemu_utimens (rpath (s, path, buffer), buf);
Hrm, I thought the SYMLINK_NOFOLLOW was critical in enforcing security?
Regards,
Anthony Liguori
Quoted 57 lines
hw/9pfs/virtio-9p-local.c +4
-0}static int local_remove (FsContext *ctx,const char *path)@@ -694,6 +693,7 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) { int err; +#ifdef FS_IOC_GETVERSION V9fsFidOpenState fid_open;/* @@ -709,6 +709,9 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, } err =ioctl (fid_open.fd,FS_IOC_GETVERSION , st_gen);local_close (ctx,&fid_open); +#else + err = -ENOTTY ; +#endif return err; }oslib-posix.c +2
-3@@ -162,8 +162,7 @@ int qemu_pipe(int pipefd[2])return ret; } -int qemu_utimensat (int dirfd,const char *path,const struct timespec *times, -int flags) +int qemu_utimens (const char *path,const struct timespec *times) {struct timeval tv[2 ], tv_now;struct stat st;@@ -171,7 +170,7 @@ int qemu_utimensat(int dirfd, const char *path, const struct timespec *times,#ifdef CONFIG_UTIMENSAT int ret; - ret =utimensat (dirfd, path, times, flags); + ret =utimensat (AT_FDCWD , path, times,AT_SYMLINK_NOFOLLOW );if (ret !=-1 || errno !=ENOSYS ) {return ret; }qemu-os-posix.h +1
-2@@ -44,7 +44,6 @@ typedef struct timeval qemu_timeval;#endif #endif typedef struct timespec qemu_timespec ; -int qemu_utimensat (int dirfd,const char *path,const qemu_timespec *times, -int flags); +int qemu_utimens (const char *path,const qemu_timespec *times);#endif
Quoted 6 lines · Anthony Liguori
hw/9pfs/virtio-9p-local.c static int local_utimensat(FsContext *s, V9fsPath *fs_path, · line 586
Quoted 4 lines
hw/9pfs/virtio-9p-local.c +1
-2-return qemu_utimensat (AT_FDCWD ,rpath (s, path, buffer), buf, -AT_SYMLINK_NOFOLLOW ); +return qemu_utimens (rpath (s, path, buffer), buf);Hrm, I thought the
SYMLINK_NOFOLLOWwas critical in enforcing security?
Yes, and it is applied by qemu_utimens automatically (but the constant only appears in a section where we know it is defined).
Paolo
Quoted 38 lines · Paolo Bonzini
Small requirements on "new" features have percolated to
virtio-9p-local.c. In particular, the utimensat wrapper actually only supports dirfd =AT_FDCWDand flags =AT_SYMLINK_NOFOLLOWin the fallback code. Remove the arguments so thatvirtio-9p-local.cwill not use AT_* constants.At the same time, fail
local_ioc_getversionif the ioctl is not supported by the host.Signed-off-by Paolo Bonzini <[email protected]>--- hw/9pfs/virtio-9p-local.c | 7 +++++-- oslib-posix.c | 5 ++--- qemu-os-posix.h | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-)hw/9pfs/virtio-9p-local.c +2
-2@@ -583,8 +583,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path,char buffer[PATH_MAX ];char *path = fs_path->data; -return qemu_utimensat (AT_FDCWD ,rpath (s, path, buffer), buf, -AT_SYMLINK_NOFOLLOW ); +return qemu_utimens (rpath (s, path, buffer), buf); }static int local_remove (FsContext *ctx,const char *path)@@ -694,6 +693,7 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) { int err; +#ifdef FS_IOC_GETVERSION V9fsFidOpenState fid_open;/*
hw/9pfs/virtio-9p-local.c static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, · line 715
Quoted 7 lines
hw/9pfs/virtio-9p-local.c +3
-0@@ -709,6 +709,9 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, } err =ioctl (fid_open.fd,FS_IOC_GETVERSION , st_gen);local_close (ctx, &fid_open); +#else + err = -ENOTTY ; +#endif return err;
I guess we can also make sure we don't call local_ioc_getversion at all.
hw/9pfs/virtio-9p-local.c +6 -1
@@ -714,10 +714,14 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path,static int local_init (FsContext *ctx) { -int err; +int err =0 ;struct statfs stbuf; ctx->export_flags |=V9FS_PATHNAME_FSCONTEXT ; +#ifdef FS_IOC_GETVERSION +/* +* use ioc_getversion only if the iocl is definied +*/ err =statfs (ctx->fs_root, &stbuf);if (!err) {switch (stbuf.f_type) {
@@ -729,6 +733,7 @@ static int local_init(FsContext *ctx) break; } } +#endif return err; }
We would also require same changes for virtio-9p-handle.c right ?
-aneesh
Quoted 1 line · Aneesh Kumar K.V
We would also require same changes for
virtio-9p-handle.cright ?
virtio-9p-handle.c is only for recent Linux and you can assume the ioctl is defined there.
Paolo
Quoted 5 lines · Paolo Bonzini
Quoted 1 line · Aneesh Kumar K.V
We would also require same changes for
virtio-9p-handle.cright ?
virtio-9p-handle.cis only for recent Linux and you can assume the ioctl is defined there.
But the file gets build by default right ? ie, we would build virtio-9p-handle.c and if FS_IOC_GETVERSION is not defined, build will fail right ?
-aneesh
Quoted 6 lines · Aneesh Kumar K.V
Quoted 3 lines
Quoted 3 lines
virtio-9p-handle.cis only for recent Linux and you can assume the ioctl is defined there.But the file gets build by default right ? ie, we would build
virtio-9p-handle.cand ifFS_IOC_GETVERSIONis not defined, build will fail right ?
I think you're right. Strange that Erik did not see it.
Paolo
Quoted 10 lines · Aneesh Kumar K.V
Quoted 9 lines · Paolo Bonzini
Small requirements on "new" features have percolated to
virtio-9p-local.c. In particular, the utimensat wrapper actually only supports dirfd =AT_FDCWDand flags =AT_SYMLINK_NOFOLLOWin the fallback code. Remove the arguments so thatvirtio-9p-local.cwill not use AT_* constants.At the same time, fail
local_ioc_getversionif the ioctl is not supported by the host.Signed-off-by Paolo Bonzini<[email protected]>
Hrm, I may have messed this up. My mailbox processing script seems to have found Aneesh's patch instead of Paolo's.
Can ya'll take a look at 2507718baf311ea78156c6777d38410a9f89ce89 and tell me if I need to revert it?
Regards,
Anthony Liguori
Quoted 77 lines
Quoted 29 lines
--- hw/9pfs/virtio-9p-local.c | 7 +++++-- oslib-posix.c | 5 ++--- qemu-os-posix.h | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-)hw/9pfs/virtio-9p-local.c +2
-2@@ -583,8 +583,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path,char buffer[PATH_MAX ];char *path = fs_path->data; -return qemu_utimensat (AT_FDCWD ,rpath (s, path, buffer), buf, -AT_SYMLINK_NOFOLLOW ); +return qemu_utimens (rpath (s, path, buffer), buf); }static int local_remove (FsContext *ctx,const char *path)@@ -694,6 +693,7 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, mode_t st_mode, uint64_t *st_gen) { int err; +#ifdef FS_IOC_GETVERSION V9fsFidOpenState fid_open;/* hw/9pfs/virtio-9p-local.c static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, · line 715
Quoted 7 lines
hw/9pfs/virtio-9p-local.c +3
-0@@ -709,6 +709,9 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, } err =ioctl (fid_open.fd,FS_IOC_GETVERSION , st_gen);local_close (ctx,&fid_open); +#else + err = -ENOTTY ; +#endif return err;I guess we can also make sure we don't call
local_ioc_getversionat all.hw/9pfs/virtio-9p-local.c +6
-1@@ -714,10 +714,14 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path,static int local_init (FsContext *ctx) { -int err; +int err =0 ;struct statfs stbuf; ctx->export_flags |=V9FS_PATHNAME_FSCONTEXT ; +#ifdef FS_IOC_GETVERSION +/* +* use ioc_getversion only if the iocl is definied +*/ err =statfs (ctx->fs_root,&stbuf);if (!err) {switch (stbuf.f_type) {@@ -729,6 +733,7 @@ static int local_init(FsContext *ctx) break; } } +#endif return err; }We would also require same changes for
virtio-9p-handle.cright ?-aneesh
Quoted 7 lines · Anthony Liguori
Quoted 1 line
Quoted 1 line
Hrm, I may have messed this up. My mailbox processing script seems to have found Aneesh's patch instead of Paolo's.
Can ya'll take a look at
2507718baf311ea78156c6777d38410a9f89ce89and tell me if I need to revert it?
No, qemu.git master is fine.
Erik, if you can test on your Debian 4.0 installation, that would be nice. Thanks!
Paolo
Quoted 9 lines · Paolo Bonzini
Quoted 7 lines · Anthony Liguori
Quoted 1 line
Quoted 1 line
Hrm, I may have messed this up. My mailbox processing script seems to have found Aneesh's patch instead of Paolo's.
Can ya'll take a look at
2507718baf311ea78156c6777d38410a9f89ce89and tell me if I need to revert it?
Quoted 7 lines
No, qemu.git master is fine.
Erik, if you can test on your Debian 4.0 installation, that would be nice. Thanks!
Paolo
I will do so. Can you provide me a snapshot (.tgz) of the git? I have heard that there are possibilities to create the tgz over some web interfaces of git, but I didn't find them. I have only very restricted web access. Please help me for this time and / or provide me a short description how to do it.
I will then try to give you feedback asap.
Thanks a lot!
Erik
Quoted 10 lines · Erik Rull
Quoted 2 lines
Erik, if you can test on your Debian 4.0 installation, that would be nice. Thanks!
I will do so. Can you provide me a snapshot (.tgz) of the git? I have heard that there are possibilities to create the tgz over some web interfaces of git, but I didn't find them. I have only very restricted web access.
Please help me for this time and / or provide me a short description how to do it.
I will then try to give you feedback asap.
You can simply test 1.0 when it comes out. Testing that it compiles would be 99% of the work. :)
Paolo
Quoted 12 lines · Paolo Bonzini
Quoted 10 lines · Erik Rull
Quoted 2 lines
Erik, if you can test on your Debian 4.0 installation, that would be nice. Thanks!
I will do so. Can you provide me a snapshot (.tgz) of the git? I have heard that there are possibilities to create the tgz over some web interfaces of git, but I didn't find them. I have only very restricted web access.
Please help me for this time and / or provide me a short description how to do it.
I will then try to give you feedback asap.
Quoted 5 lines
You can simply test 1.0 when it comes out. Testing that it compiles would be 99% of the work. :)
Paolo
No, it does not compile :-( See my mail 2011-12-02 14:22
Best regards,
Erik
Quoted 12 lines · Paolo Bonzini
Quoted 10 lines · Erik Rull
Quoted 2 lines
Erik, if you can test on your Debian 4.0 installation, that would be nice. Thanks!
I will do so. Can you provide me a snapshot (.tgz) of the git? I have heard that there are possibilities to create the tgz over some web interfaces of git, but I didn't find them. I have only very restricted web access.
Please help me for this time and / or provide me a short description how to do it.
I will then try to give you feedback asap.
Quoted 5 lines
You can simply test 1.0 when it comes out. Testing that it compiles would be 99% of the work. :)
Paolo
No, it does not compile :-( See my mail 2011-12-02 14:22
Best regards,
Erik
Quoted 10 lines · Anthony Liguori
Quoted 9 lines · Aneesh Kumar K.V
Quoted 8 lines · Paolo Bonzini
Small requirements on "new" features have percolated to
virtio-9p-local.c. In particular, the utimensat wrapper actually only supports dirfd =AT_FDCWDand flags =AT_SYMLINK_NOFOLLOWin the fallback code. Remove the arguments so thatvirtio-9p-local.cwill not use AT_* constants.At the same time, fail
local_ioc_getversionif the ioctl is not supported by the host.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Paolo Bonzini<[email protected]>Hrm, I may have messed this up. My mailbox processing script seems to have found Aneesh's patch instead of Paolo's.
Can ya'll take a look at
2507718baf311ea78156c6777d38410a9f89ce89and tell me if I need to revert it?
No i don't think that needs a revert. But we may need the below patch. I have also send the change as a separate mail to the list.
Quoted 1 line
From
db7fdc1c8eb95d556c18ee44fd4f9d5a3aabf9c4Mon Sep 17 00:00:00 2001
From: "Aneesh Kumar K.V" <[email protected]>
Date: Tue, 29 Nov 2011 15:10:52 +0530
Subject: [PATCH] hw/9pfs: Improve portability to older systems
commit ae0f940e6b4f5177892dd6a12762282fa9089972 2507718baf311ea78156c6777d38410a9f89ce89 missed updating virtio-9p-handle.c.
--- hw/9pfs/virtio-9p-handle.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
hw/9pfs/virtio-9p-handle.c +5 -1
@@ -599,7 +599,8 @@ static int handle_unlinkat(FsContext *ctx, V9fsPath *dir,static int handle_ioc_getversion (FsContext *ctx,V9fsPath *path,mode_t st_mode,uint64_t *st_gen) { -int err; +int err = -ENOTTY ; +#ifdef FS_IOC_GETVERSION V9fsFidOpenState fid_open;/*
@@ -615,6 +616,7 @@ static int handle_ioc_getversion(FsContext *ctx, V9fsPath *path, } err =ioctl (fid_open.fd,FS_IOC_GETVERSION , st_gen);handle_close (ctx, &fid_open); +#endif return err; }
@@ -630,6 +632,7 @@ static int handle_init(FsContext *ctx) ret = data->mountfd; goto err_out; } +#ifdef FS_IOC_GETVERSION ret =statfs (ctx->fs_root, &stbuf);if (!ret) {switch (stbuf.f_type) {
@@ -641,6 +644,7 @@ static int handle_init(FsContext *ctx) break; } } +#endif memset (&fh,0 ,sizeof (struct file_handle )); ret =name_to_handle (data->mountfd,"." , &fh, &mnt_id,0 );if (ret && errno ==EOVERFLOW ) {
Signature · 1 line
1.7.5.4