Skip to content

Commit 22c1ea4

Browse files
Andreas GruenbacherLinus Torvalds
authored andcommitted
[PATCH] nfsacl: Solaris VxFS compatibility fix
Here is a compatibility fix between Linux and Solaris when used with VxFS filesystems: Solaris usually accepts acl entries in any order, but with VxFS it replies with NFSERR_INVAL when it sees a four-entry acl that is not in canonical form. It may also fail with other non-canonical acls -- I can't tell, because that case never triggers: We only send non-canonical acls when we fake up an ACL_MASK entry. Instead of adding fake ACL_MASK entries at the end, inserting them in the correct position makes Solaris+VxFS happy. The Linux client and server sides don't care about entry order. The three-entry-acl special case in which we need a fake ACL_MASK entry was handled in xdr_nfsace_encode. The patch moves this into nfsacl_encode. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 19cba8a commit 22c1ea4

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

‎fs/nfs_common/nfsacl.c‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,26 @@ xdr_nfsace_encode(struct xdr_array2_desc *desc, void *elem)
4848
(struct nfsacl_encode_desc *) desc;
4949
u32 *p = (u32 *) elem;
5050

51-
if (nfsacl_desc->count < nfsacl_desc->acl->a_count) {
52-
struct posix_acl_entry *entry =
53-
&nfsacl_desc->acl->a_entries[nfsacl_desc->count++];
51+
struct posix_acl_entry *entry =
52+
&nfsacl_desc->acl->a_entries[nfsacl_desc->count++];
5453

55-
*p++ = htonl(entry->e_tag | nfsacl_desc->typeflag);
56-
switch(entry->e_tag) {
57-
case ACL_USER_OBJ:
58-
*p++ = htonl(nfsacl_desc->uid);
59-
break;
60-
case ACL_GROUP_OBJ:
61-
*p++ = htonl(nfsacl_desc->gid);
62-
break;
63-
case ACL_USER:
64-
case ACL_GROUP:
65-
*p++ = htonl(entry->e_id);
66-
break;
67-
default: /* Solaris depends on that! */
68-
*p++ = 0;
69-
break;
70-
}
71-
*p++ = htonl(entry->e_perm & S_IRWXO);
72-
} else {
73-
const struct posix_acl_entry *pa, *pe;
74-
int group_obj_perm = ACL_READ|ACL_WRITE|ACL_EXECUTE;
75-
76-
FOREACH_ACL_ENTRY(pa, nfsacl_desc->acl, pe) {
77-
if (pa->e_tag == ACL_GROUP_OBJ) {
78-
group_obj_perm = pa->e_perm & S_IRWXO;
79-
break;
80-
}
81-
}
82-
/* fake up ACL_MASK entry */
83-
*p++ = htonl(ACL_MASK | nfsacl_desc->typeflag);
84-
*p++ = htonl(0);
85-
*p++ = htonl(group_obj_perm);
54+
*p++ = htonl(entry->e_tag | nfsacl_desc->typeflag);
55+
switch(entry->e_tag) {
56+
case ACL_USER_OBJ:
57+
*p++ = htonl(nfsacl_desc->uid);
58+
break;
59+
case ACL_GROUP_OBJ:
60+
*p++ = htonl(nfsacl_desc->gid);
61+
break;
62+
case ACL_USER:
63+
case ACL_GROUP:
64+
*p++ = htonl(entry->e_id);
65+
break;
66+
default: /* Solaris depends on that! */
67+
*p++ = 0;
68+
break;
8669
}
87-
70+
*p++ = htonl(entry->e_perm & S_IRWXO);
8871
return 0;
8972
}
9073

@@ -105,11 +88,28 @@ nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
10588
.gid = inode->i_gid,
10689
};
10790
int err;
91+
struct posix_acl *acl2 = NULL;
10892

10993
if (entries > NFS_ACL_MAX_ENTRIES ||
11094
xdr_encode_word(buf, base, entries))
11195
return -EINVAL;
96+
if (encode_entries && acl && acl->a_count == 3) {
97+
/* Fake up an ACL_MASK entry. */
98+
acl2 = posix_acl_alloc(4, GFP_KERNEL);
99+
if (!acl2)
100+
return -ENOMEM;
101+
/* Insert entries in canonical order: other orders seem
102+
to confuse Solaris VxFS. */
103+
acl2->a_entries[0] = acl->a_entries[0]; /* ACL_USER_OBJ */
104+
acl2->a_entries[1] = acl->a_entries[1]; /* ACL_GROUP_OBJ */
105+
acl2->a_entries[2] = acl->a_entries[1]; /* ACL_MASK */
106+
acl2->a_entries[2].e_tag = ACL_MASK;
107+
acl2->a_entries[3] = acl->a_entries[2]; /* ACL_OTHER */
108+
nfsacl_desc.acl = acl2;
109+
}
112110
err = xdr_encode_array2(buf, base + 4, &nfsacl_desc.desc);
111+
if (acl2)
112+
posix_acl_release(acl2);
113113
if (!err)
114114
err = 8 + nfsacl_desc.desc.elem_size *
115115
nfsacl_desc.desc.array_len;

0 commit comments

Comments
 (0)