]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
fix vfs/utils.c for big-endian systems
authorEric Sandeen <sandeen@redhat.com>
Mon, 27 Jan 2025 21:43:24 +0000 (15:43 -0600)
committerZorro Lang <zlang@kernel.org>
Sun, 2 Feb 2025 13:28:37 +0000 (21:28 +0800)
generic/633 was failing with EINVAL on the fsxgetattr call on s390.
Looks like this is due to a failure to properly endian swap the
arguments to the syscall, so fix that, and the magic_etc compare
in expected_dummy_vfs_caps_uid() as well while we're at it.

Fixes: 0d1af68e ("generic: add fstests for idmapped mounts")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/vfs/utils.c

index c1c7951c46fe807f3e562688ecbc9c0f9ba33b1c..52bb7e4280462c483c77a7ca33c1daca3f8e3d0d 100644 (file)
@@ -650,7 +650,7 @@ bool expected_dummy_vfs_caps_uid(int fd, uid_t expected_uid)
        if (ret < 0 || ret == 0)
                return false;
 
-       if (ns_xattr.magic_etc & VFS_CAP_REVISION_3) {
+       if (le32_to_cpu(ns_xattr.magic_etc) & VFS_CAP_REVISION_3) {
 
                if (le32_to_cpu(ns_xattr.rootid) != expected_uid) {
                        errno = EINVAL;
@@ -673,10 +673,12 @@ int set_dummy_vfs_caps(int fd, int flags, int rootuid)
        ns_cap_data.data[(x) >> 5].permitted |= (1 << ((x)&31))
 
        struct vfs_ns_cap_data ns_xattr;
+       __le32 magic_etc;
 
        memset(&ns_xattr, 0, sizeof(ns_xattr));
        __raise_cap_permitted(CAP_NET_RAW, ns_xattr);
-       ns_xattr.magic_etc |= VFS_CAP_REVISION_3 | VFS_CAP_FLAGS_EFFECTIVE;
+       magic_etc = (VFS_CAP_REVISION_3 | VFS_CAP_FLAGS_EFFECTIVE);
+       ns_xattr.magic_etc |= cpu_to_le32(magic_etc);
        ns_xattr.rootid = cpu_to_le32(rootuid);
 
        return fsetxattr(fd, "security.capability",