Blame 0103-hw-9pfs-Fix-errno-value-for-xattr-functions.patch

298366
From 6f7e1d2bddb5a0a1c65f6f02467460d6edbcc901 Mon Sep 17 00:00:00 2001
298366
From: "Daniel P. Berrange" <berrange@redhat.com>
298366
Date: Tue, 1 Oct 2013 12:28:17 +0100
298366
Subject: [PATCH] hw/9pfs: Fix errno value for xattr functions
298366
298366
If there is no operation driver for the xattr type the
298366
functions return '-1' and set errno to '-EOPNOTSUPP'.
298366
When the calling code sets 'ret = -errno' this turns
298366
into a large positive number.
298366
298366
In Linux 3.11, the kernel has switched to using 9p
298366
version 9p2000.L, instead of 9p2000.u, which enables
298366
support for xattr operations. This on its own is harmless,
298366
but for another change which makes it request the xattr
298366
with a name 'security.capability'.
298366
298366
The result is that the guest sees a succesful return
298366
of 95 bytes of data, instead of a failure with errno
298366
set to 95. Since the kernel expects a maximum of 20
298366
bytes for an xattr return this gets translated to the
298366
unexpected errno ERANGE.
298366
298366
This all means that when running a binary off a 9p fs
298366
in 3.11 kernels you get a fun result of:
298366
298366
  # ./date
298366
  sh: ./date: Numerical result out of range
298366
298366
The only workaround is to pass 'version=9p2000.u' when
298366
mounting the 9p fs in the guest, to disable all use of
298366
xattrs.
298366
298366
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
298366
---
298366
 hw/9pfs/virtio-9p-xattr.c | 6 +++---
298366
 1 file changed, 3 insertions(+), 3 deletions(-)
298366
298366
diff --git a/hw/9pfs/virtio-9p-xattr.c b/hw/9pfs/virtio-9p-xattr.c
298366
index 90ae565..3fae557 100644
298366
--- a/hw/9pfs/virtio-9p-xattr.c
298366
+++ b/hw/9pfs/virtio-9p-xattr.c
298366
@@ -36,7 +36,7 @@ ssize_t v9fs_get_xattr(FsContext *ctx, const char *path,
298366
     if (xops) {
298366
         return xops->getxattr(ctx, path, name, value, size);
298366
     }
298366
-    errno = -EOPNOTSUPP;
298366
+    errno = EOPNOTSUPP;
298366
     return -1;
298366
 }
298366
 
298366
@@ -123,7 +123,7 @@ int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name,
298366
     if (xops) {
298366
         return xops->setxattr(ctx, path, name, value, size, flags);
298366
     }
298366
-    errno = -EOPNOTSUPP;
298366
+    errno = EOPNOTSUPP;
298366
     return -1;
298366
 
298366
 }
298366
@@ -135,7 +135,7 @@ int v9fs_remove_xattr(FsContext *ctx,
298366
     if (xops) {
298366
         return xops->removexattr(ctx, path, name);
298366
     }
298366
-    errno = -EOPNOTSUPP;
298366
+    errno = EOPNOTSUPP;
298366
     return -1;
298366
 
298366
 }