summary refs log tree commit diff stats
path: root/scripts/qapi/types.py
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2021-06-22 11:08:47 -0400
committerDr. David Alan Gilbert <dgilbert@redhat.com>2021-07-05 10:51:26 +0100
commit5290fb625d1bf692306ee958efc67c8620866f67 (patch)
tree69c367194225f57f1f1300288b6c6bd2ced303f1 /scripts/qapi/types.py
parent061624455fc3e4a19caeba321b284548127d858e (diff)
downloadfocaccia-qemu-5290fb625d1bf692306ee958efc67c8620866f67.tar.gz
focaccia-qemu-5290fb625d1bf692306ee958efc67c8620866f67.zip
virtiofsd: Fix xattr operations overwriting errno
getxattr/setxattr/removexattr/listxattr operations handle regualar
and non-regular files differently. For the case of non-regular files
we do fchdir(/proc/self/fd) and the xattr operation and then revert
back to original working directory. After this we are saving errno
and that's buggy because fchdir() will overwrite the errno.

FCHDIR_NOFAIL(lo->proc_self_fd);
ret = getxattr(procname, name, value, size);
FCHDIR_NOFAIL(lo->root.fd);

if (ret == -1)
    saverr = errno

In above example, if getxattr() failed, we will still return 0 to caller
as errno must have been written by FCHDIR_NOFAIL(lo->root.fd) call.
Fix all such instances and capture "errno" early and save in "saverr"
variable.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Message-Id: <20210622150852.1507204-3-vgoyal@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'scripts/qapi/types.py')
0 files changed, 0 insertions, 0 deletions