From patchwork Sun Oct 6 09:32:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 280841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 10CC72C00AA for ; Sun, 6 Oct 2013 20:40:02 +1100 (EST) Received: from localhost ([::1]:54309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSkoi-0006dV-3P for incoming@patchwork.ozlabs.org; Sun, 06 Oct 2013 05:40:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSko2-0006Vy-FY for qemu-devel@nongnu.org; Sun, 06 Oct 2013 05:39:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSknv-0003M0-VY for qemu-devel@nongnu.org; Sun, 06 Oct 2013 05:39:18 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:47960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSknv-0003LQ-Md; Sun, 06 Oct 2013 05:39:11 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id EA04540CAE; Sun, 6 Oct 2013 13:39:09 +0400 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id DED0B522; Sun, 6 Oct 2013 13:33:03 +0400 (MSK) Received: (nullmailer pid 25825 invoked by uid 1000); Sun, 06 Oct 2013 09:33:02 -0000 From: Michael Tokarev To: aliguori@us.ibm.com Date: Sun, 6 Oct 2013 13:32:57 +0400 Message-Id: <1381051979-25742-13-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1381051979-25742-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1381051979-25742-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Michael Tokarev , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 12/14] hw/9pfs: Fix errno value for xattr functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Daniel P. Berrange" If there is no operation driver for the xattr type the functions return '-1' and set errno to '-EOPNOTSUPP'. When the calling code sets 'ret = -errno' this turns into a large positive number. In Linux 3.11, the kernel has switched to using 9p version 9p2000.L, instead of 9p2000.u, which enables support for xattr operations. This on its own is harmless, but for another change which makes it request the xattr with a name 'security.capability'. The result is that the guest sees a succesful return of 95 bytes of data, instead of a failure with errno set to 95. Since the kernel expects a maximum of 20 bytes for an xattr return this gets translated to the unexpected errno ERANGE. This all means that when running a binary off a 9p fs in 3.11 kernels you get a fun result of: # ./date sh: ./date: Numerical result out of range The only workaround is to pass 'version=9p2000.u' when mounting the 9p fs in the guest, to disable all use of xattrs. Signed-off-by: Daniel P. Berrange Reviewed-by: Aneesh Kumar K.V Signed-off-by: Michael Tokarev --- hw/9pfs/virtio-9p-xattr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/virtio-9p-xattr.c b/hw/9pfs/virtio-9p-xattr.c index 90ae565..3fae557 100644 --- a/hw/9pfs/virtio-9p-xattr.c +++ b/hw/9pfs/virtio-9p-xattr.c @@ -36,7 +36,7 @@ ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, if (xops) { return xops->getxattr(ctx, path, name, value, size); } - errno = -EOPNOTSUPP; + errno = EOPNOTSUPP; return -1; } @@ -123,7 +123,7 @@ int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name, if (xops) { return xops->setxattr(ctx, path, name, value, size, flags); } - errno = -EOPNOTSUPP; + errno = EOPNOTSUPP; return -1; } @@ -135,7 +135,7 @@ int v9fs_remove_xattr(FsContext *ctx, if (xops) { return xops->removexattr(ctx, path, name); } - errno = -EOPNOTSUPP; + errno = EOPNOTSUPP; return -1; }