Skip to contentSkip to conversation

Convert server-side NFS_ACLv3 XDR to use xdrgen

PATCH In review Chuck Lever 3 participants 16 messages Oct 26 – Oct 27

Subsystems (3)
lore
Share & tools
lore

Chuck Lever

author maintainer
#0 lore raw

cover Convert server-side NFS_ACLv3 XDR to use xdrgen

Replace NFSD's NFS_ACLv3 XDR encoders and decoders with code that is mechanically generated from the protocol's RPC language description. No RFC defines NFS_ACL. The description in nfs_acl3.x is copied from draft-ietf-nfsv4-nfs-acl.

Chuck Lever (13):
Documentation: Add the RPC language description of NFS_ACLv3
NFSD: Add infrastructure for generating NFS_ACLv3 XDR encoders and
decoders
NFSD: Remove '#include "xdr3.h"' from nfs3acl.c
NFSD: New NFS_ACLv3 status codes
NFSD: Use xdrgen XDR functions for the NFS-ACL v3 NULL procedure
NFSD: Implement NFS-ACL v3 ACL encoding and decoding with xdrgen
NFSD: Use xdrgen XDR functions for the NFS-ACL v3 GETACL procedure
NFSD: Use xdrgen XDR functions for the NFS-ACL v3 SETACL procedure
NFSD: Map every NFS_ACLv3 reply status into aclstat3
NFSD: Remove the hand-coded XDR helpers for the NFS_ACLv3 procedures
NFS: Move NFSACL_MAXPAGES into fs/nfs/nfs3_fs.h
NFSD: Share the attribute conversion helpers with the NFS_ACL procs
nfs_common: Remove the unused NFS ACL stream codecs

 Documentation/sunrpc/xdr/nfs_acl3.x    | 273 ++++++++
 fs/nfs/nfs3_fs.h                       |   3 +
 fs/nfs/nfs3xdr.c                       |   1 +
 fs/nfs_common/nfsacl.c                 | 125 ----
 fs/nfsd/Makefile                       |  13 +-
 fs/nfsd/fattr.h                        |  20 +
 fs/nfsd/nfs2acl.c                      |  99 +--
 fs/nfsd/nfs3acl.c                      | 623 +++++++++++++-----
 fs/nfsd/nfs3xdr.c                      | 166 -----
 fs/nfsd/nfs_acl3xdr_gen.c              | 839 +++++++++++++++++++++++++
 fs/nfsd/nfs_acl3xdr_gen.h              |  36 ++
 fs/nfsd/nfsproc.c                      |   3 +-
 fs/nfsd/xdr3.h                         |   8 +-
 include/linux/nfsacl.h                 |   9 -
 include/linux/sunrpc/xdrgen/nfs_acl3.h | 284 +++++++++
 15 files changed, 1948 insertions(+), 554 deletions(-)
 create mode 100644 Documentation/sunrpc/xdr/nfs_acl3.x
 create mode 100644 fs/nfsd/fattr.h
 create mode 100644 fs/nfsd/nfs_acl3xdr_gen.c
 create mode 100644 fs/nfsd/nfs_acl3xdr_gen.h
 create mode 100644 include/linux/sunrpc/xdrgen/nfs_acl3.h
Signature · 1 line
2.56.0
author maintainer
#1 lore raw

PATCH 1/13 Documentation: Add the RPC language description of NFS_ACLv3

Converting nfs3acl.c from hand-written XDR codecs to xdrgen-generated code first requires a machine-readable description of the protocol for xdrgen to process. Include a copy of the RPC language description of NFS_ACLv3, taken from the NFS ACL protocol specification.

The description carries no pragmas. Later patches add the header, aggregate, and endianness pragmas as the generated code that needs each one is introduced.

---
 Documentation/sunrpc/xdr/nfs_acl3.x | 268 ++++++++++++++++++++++++++++
 1 file changed, 268 insertions(+)
 create mode 100644 Documentation/sunrpc/xdr/nfs_acl3.x
Documentation/sunrpc/xdr/nfs_acl3.x new file +268 -0
new file mode 100644
index 000000000000..913ecf3a369f
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2024 IETF Trust and the persons
+ * identified as authors of the code.  All rights reserved.
+ *
+ * The authors of the code are:
+ * Oracle
+ *
+ * Redistribution and use in source and binary forms, with
+ * or without modification, are permitted provided that the
+ * following conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the
+ *   following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the
+ *   following disclaimer in the documentation and/or other
+ *   materials provided with the distribution.
+ *
+ * - Neither the name of Internet Society, IETF or IETF
+ *   Trust, nor the names of specific contributors, may be
+ *   used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
+ *   AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ *   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
+ *   EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ *   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ *   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ *   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+const NFS_ACL_MAX_ENTRIES = 1024;
+
+typedef unsigned int uid;
+typedef unsigned short o_mode;
+
+/*
+ * This is the format of an ACL which is passed over the network.
+ */
+struct aclent {
+    int type;
+    uid id;
+    o_mode perm;
+};
+
+/*
+ * The values for the type element of the aclent structure.
+ */
+const NA_USER_OBJ = 0x1;            /* object owner */
+const NA_USER = 0x2;                /* additional users */
+const NA_GROUP_OBJ = 0x4;           /* owning group of the object */
+const NA_GROUP = 0x8;               /* additional groups */
+const NA_CLASS_OBJ = 0x10;          /* file group class and mask entry */
+const NA_OTHER_OBJ = 0x20;          /* other entry for the object */
+const NA_ACL_DEFAULT = 0x1000;      /* default flag */
+
+/*
+ * The bit field values for the perm element of the aclent
+ * structure.  The three values can be combined to form any
+ * of the 8 combinations.
+ */
+const NA_READ = 0x4;                /* read permission */
+const NA_WRITE = 0x2;               /* write permission */
+const NA_EXEC = 0x1;                /* exec permission */
+
+/*
+ * This is the structure which contains the ACL entries for a
+ * particular entity.  It contains the ACL entries which apply
+ * to this object plus any default ACL entries which are
+ * inherited by its children.
+ *
+ * The values for the mask field are defined below.
+ */
+struct secattr {
+    unsigned int mask;
+    int aclcnt;
+    aclent aclent<NFS_ACL_MAX_ENTRIES>;
+    int dfaclcnt;
+    aclent dfaclent<NFS_ACL_MAX_ENTRIES>;
+};
+
+/*
+ * The values for the mask element of the secattr struct as well
+ * as for the mask element in the arguments in the GETACL2 and
+ * GETACL3 procedures.
+ */
+const NA_ACL = 0x1;                 /* aclent contains a valid list */
+const NA_ACLCNT = 0x2;              /* number of entries in the aclent list */
+const NA_DFACL = 0x4;               /* dfaclent contains a valid list */
+const NA_DFACLCNT = 0x8;            /* number of entries in the dfaclent list */
+
+/*
+ * Share the ports with the NFS service.
+ */
+const NFS_ACL_PORT = 2049;
+const NFS_ACL_RDMA_PORT = 20049;
+
+/*
+ * XDR data types inherited from the NFS version 3 protocol
+ */
+
+typedef unsigned hyper uint64;
+typedef unsigned long uint32;
+typedef uint64 fileid3;
+typedef uint32 uid3;
+typedef uint32 gid3;
+typedef uint64 size3;
+typedef uint32 mode3;
+
+enum ftype3 {
+    NF3REG    = 1,
+    NF3DIR    = 2,
+    NF3BLK    = 3,
+    NF3CHR    = 4,
+    NF3LNK    = 5,
+    NF3SOCK   = 6,
+    NF3FIFO   = 7
+};
+
+struct specdata3 {
+    uint32     specdata1;
+    uint32     specdata2;
+};
+
+const NFS3_FHSIZE = 64;
+
+struct nfs_fh3 {
+    opaque       data<NFS3_FHSIZE>;
+};
+
+struct nfstime3 {
+    uint32   seconds;
+    uint32   nseconds;
+};
+
+struct fattr3 {
+    ftype3     type;
+    mode3      mode;
+    uint32     nlink;
+    uid3       uid;
+    gid3       gid;
+    size3      size;
+    size3      used;
+    specdata3  rdev;
+    uint64     fsid;
+    fileid3    fileid;
+    nfstime3   atime;
+    nfstime3   mtime;
+    nfstime3   ctime;
+};
+
+union post_op_attr switch (bool attributes_follow) {
+case TRUE:
+    fattr3   attributes;
+case FALSE:
+    void;
+};
+
+/*
+ * ACL error codes; the numeric values match codes with the same
+ * name used in NFS version 3.
+ */
+enum aclstat3 {
+    ACL3_OK = 0,
+    ACL3ERR_PERM = 1,
+    ACL3ERR_NOENT = 2,
+    ACL3ERR_IO = 5,
+    ACL3ERR_ACCES = 13,
+    ACL3ERR_INVAL = 22,
+    ACL3ERR_NOSPC = 28,
+    ACL3ERR_ROFS = 30,
+    ACL3ERR_DQUOT = 69,
+    ACL3ERR_STALE = 70,
+    ACL3ERR_BADHANDLE = 10001,
+    ACL3ERR_NOTSUPP = 10004,
+    ACL3ERR_SERVERFAULT = 10006,
+    ACL3ERR_JUKEBOX = 10008
+};
+
+/*
+ * NFS_ACL version 3 procedure arguments and results
+ */
+
+struct GETACL3args {
+    nfs_fh3 fh;
+    unsigned int mask;
+};
+
+struct GETACL3resok {
+    post_op_attr attr;
+    secattr acl;
+};
+
+struct GETACL3resfail {
+    post_op_attr attr;
+};
+
+union GETACL3res switch (aclstat3 status) {
+case ACL3_OK:
+    GETACL3resok resok;
+default:
+    GETACL3resfail resfail;
+};
+
+struct SETACL3args {
+    nfs_fh3 fh;
+    secattr acl;
+};
+
+struct SETACL3resok {
+    post_op_attr attr;
+};
+
+struct SETACL3resfail {
+    post_op_attr attr;
+};
+
+union SETACL3res switch (aclstat3 status) {
+case ACL3_OK:
+    SETACL3resok resok;
+default:
+    SETACL3resfail resfail;
+};
+
+/*
+ * This is the definition for the GETXATTRDIR procedure which
+ * applies to NFS Version 3 files.
+ */
+struct GETXATTRDIR3args {
+    nfs_fh3 fh;
+    bool create;
+};
+
+struct GETXATTRDIR3resok {
+    nfs_fh3 fh;
+    post_op_attr attr;
+};
+
+union GETXATTRDIR3res switch (aclstat3 status) {
+case ACL3_OK:
+    GETXATTRDIR3resok resok;
+default:
+    void;
+};
+
+program NFS_ACL_PROGRAM {
+    version NFS_ACL_V3 {
+        void
+            ACLPROC3_NULL(void) = 0;
+        GETACL3res
+            ACLPROC3_GETACL(GETACL3args) = 1;
+        SETACL3res
+            ACLPROC3_SETACL(SETACL3args) = 2;
+        GETXATTRDIR3res
+            ACLPROC3_GETXATTRDIR(GETXATTRDIR3args) = 3;
+    } = 3;
+} = 100227;
Signature · 1 line
2.56.0
author maintainer
#2 lore raw

PATCH 2/13 NFSD: Add infrastructure for generating NFS_ACLv3 XDR encoders and decoders

In reply to Chuck Lever

NFSD's NFS_ACLv3 XDR codecs are hand-maintained; they are being converted to xdrgen-generated code one RPC procedure at a time. The first step is to generate and commit the xdrgen C code based on nfs_acl3.x. The generated code can be refreshed any time nfs_acl3.x is modified by running "(cd fs/nfsd && make xdrgen)"

---
 Documentation/sunrpc/xdr/nfs_acl3.x    |   2 +
 fs/nfsd/Makefile                       |  13 +-
 fs/nfsd/nfs_acl3xdr_gen.c              | 749 +++++++++++++++++++++++++
 fs/nfsd/nfs_acl3xdr_gen.h              |  24 +
 include/linux/sunrpc/xdrgen/nfs_acl3.h | 284 ++++++++++
 5 files changed, 1069 insertions(+), 3 deletions(-)
 create mode 100644 fs/nfsd/nfs_acl3xdr_gen.c
 create mode 100644 fs/nfsd/nfs_acl3xdr_gen.h
 create mode 100644 include/linux/sunrpc/xdrgen/nfs_acl3.h
Documentation/sunrpc/xdr/nfs_acl3.x +2 -0
index 913ecf3a369f..b0e1d2e1fd43 100644
@@ -40,6 +40,8 @@
  *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+pragma header nfs_acl3;
+
 const NFS_ACL_MAX_ENTRIES = 1024;
 
 typedef unsigned int uid;
fs/nfsd/Makefile +10 -3
index 7db3b248e15a..96af6d479731 100644
@@ -16,7 +16,7 @@ nfsd-y 			+= nfssvc.o nfsctl.o nfsfh.o vfs.o \
 			   nfs3proc.o nfs3xdr.o nfs3xdr_gen.o
 nfsd-$(CONFIG_NFSD_V2) += nfsproc.o nfsxdr.o nfs2xdr_gen.o
 nfsd-$(CONFIG_NFSD_V2_ACL) += nfs2acl.o nfs_acl2xdr_gen.o
-nfsd-$(CONFIG_NFSD_V3_ACL) += nfs3acl.o
+nfsd-$(CONFIG_NFSD_V3_ACL) += nfs3acl.o nfs_acl3xdr_gen.o
 nfsd-$(CONFIG_NFSD_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4idmap.o \
 			   nfs4acl.o nfs4callback.o nfs4recover.o nfs4xdr_gen.o
 nfsd-$(CONFIG_NFSD_PNFS) += nfs4layouts.o
@@ -40,11 +40,12 @@ nfsd-$(CONFIG_DEBUG_FS) += debugfs.o
 XDRGEN_DEFINITIONS	= ../../include/linux/sunrpc/xdrgen/nfs2.h \
 			  ../../include/linux/sunrpc/xdrgen/nfs_acl2.h \
 			  ../../include/linux/sunrpc/xdrgen/nfs3.h \
+			  ../../include/linux/sunrpc/xdrgen/nfs_acl3.h \
 			  ../../include/linux/sunrpc/xdrgen/nfs4_1.h
 XDRGEN_DECLARATIONS	= nfs2xdr_gen.h nfs_acl2xdr_gen.h \
-			  nfs3xdr_gen.h nfs4xdr_gen.h
+			  nfs3xdr_gen.h nfs_acl3xdr_gen.h nfs4xdr_gen.h
 XDRGEN_SOURCE		= nfs2xdr_gen.c nfs_acl2xdr_gen.c \
-			  nfs3xdr_gen.c nfs4xdr_gen.c
+			  nfs3xdr_gen.c nfs_acl3xdr_gen.c nfs4xdr_gen.c
 
 xdrgen: $(XDRGEN_DEFINITIONS) $(XDRGEN_DECLARATIONS) $(XDRGEN_SOURCE)
 
@@ -54,6 +55,8 @@ xdrgen: $(XDRGEN_DEFINITIONS) $(XDRGEN_DECLARATIONS) $(XDRGEN_SOURCE)
 	../../tools/net/sunrpc/xdrgen/xdrgen definitions $< > $@
 ../../include/linux/sunrpc/xdrgen/nfs3.h: ../../Documentation/sunrpc/xdr/nfs3.x
 	../../tools/net/sunrpc/xdrgen/xdrgen definitions $< > $@
+../../include/linux/sunrpc/xdrgen/nfs_acl3.h: ../../Documentation/sunrpc/xdr/nfs_acl3.x
+	../../tools/net/sunrpc/xdrgen/xdrgen definitions $< > $@
 ../../include/linux/sunrpc/xdrgen/nfs4_1.h: ../../Documentation/sunrpc/xdr/nfs4_1.x
 	../../tools/net/sunrpc/xdrgen/xdrgen definitions $< > $@
 
@@ -63,6 +66,8 @@ nfs_acl2xdr_gen.h: ../../Documentation/sunrpc/xdr/nfs_acl2.x
 	../../tools/net/sunrpc/xdrgen/xdrgen declarations $< > $@
 nfs3xdr_gen.h: ../../Documentation/sunrpc/xdr/nfs3.x
 	../../tools/net/sunrpc/xdrgen/xdrgen declarations $< > $@
+nfs_acl3xdr_gen.h: ../../Documentation/sunrpc/xdr/nfs_acl3.x
+	../../tools/net/sunrpc/xdrgen/xdrgen declarations $< > $@
 nfs4xdr_gen.h: ../../Documentation/sunrpc/xdr/nfs4_1.x
 	../../tools/net/sunrpc/xdrgen/xdrgen declarations $< > $@
 
@@ -72,5 +77,7 @@ nfs_acl2xdr_gen.c: ../../Documentation/sunrpc/xdr/nfs_acl2.x
 	../../tools/net/sunrpc/xdrgen/xdrgen source $< > $@
 nfs3xdr_gen.c: ../../Documentation/sunrpc/xdr/nfs3.x
 	../../tools/net/sunrpc/xdrgen/xdrgen source $< > $@
+nfs_acl3xdr_gen.c: ../../Documentation/sunrpc/xdr/nfs_acl3.x
+	../../tools/net/sunrpc/xdrgen/xdrgen source $< > $@
 nfs4xdr_gen.c: ../../Documentation/sunrpc/xdr/nfs4_1.x
 	../../tools/net/sunrpc/xdrgen/xdrgen source $< > $@
fs/nfsd/nfs_acl3xdr_gen.c new file +749 -0

749 lines not on this page · raw message

fs/nfsd/nfs_acl3xdr_gen.h new file +24 -0
new file mode 100644
index 000000000000..d778004ba26a
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Generated by xdrgen. Manual edits will be lost. */
+/* XDR specification file: ../../Documentation/sunrpc/xdr/nfs_acl3.x */
+/* XDR specification modification time: Fri Jul 10 20:10:15 2026 */
+
+#ifndef _LINUX_XDRGEN_NFS_ACL3_DECL_H
+#define _LINUX_XDRGEN_NFS_ACL3_DECL_H
+
+#include <linux/types.h>
+
+#include <linux/sunrpc/xdr.h>
+#include <linux/sunrpc/xdrgen/_defs.h>
+#include <linux/sunrpc/xdrgen/_builtins.h>
+#include <linux/sunrpc/xdrgen/nfs_acl3.h>
+
+bool nfs_acl_svc_decode_GETACL3args(struct svc_rqst *rqstp, struct xdr_stream *xdr);
+bool nfs_acl_svc_decode_SETACL3args(struct svc_rqst *rqstp, struct xdr_stream *xdr);
+bool nfs_acl_svc_decode_GETXATTRDIR3args(struct svc_rqst *rqstp, struct xdr_stream *xdr);
+
+bool nfs_acl_svc_encode_GETACL3res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
+bool nfs_acl_svc_encode_SETACL3res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
+bool nfs_acl_svc_encode_GETXATTRDIR3res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
+
+#endif /* _LINUX_XDRGEN_NFS_ACL3_DECL_H */
include/linux/sunrpc/xdrgen/nfs_acl3.h new file +284 -0

284 lines not on this page · raw message

Signature · 1 line
2.56.0
author maintainer
#3 lore raw

PATCH 3/13 NFSD: Remove '#include "xdr3.h"' from nfs3acl.c

In reply to Chuck Lever

Begin the process of converting nfs3acl.c to use xdrgen by removing the xdr3.h header from nfs3acl.c. Eventually nfs3acl.c will use only NFS_ACLv3 headers.

---
 fs/nfsd/nfs3acl.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
fs/nfsd/nfs3acl.c +33 -1
index 58f1297c88f9..98de13b44a80 100644
@@ -13,9 +13,41 @@
 #include <linux/gfp.h>
 
 #include "cache.h"
-#include "xdr3.h"
 #include "vfs.h"
 
+struct nfsd3_getaclargs {
+	struct svc_fh		fh;
+	__u32			mask;
+};
+
+struct nfsd3_getaclres {
+	__be32			status;
+	struct svc_fh		fh;
+	int			mask;
+	struct posix_acl	*acl_access;
+	struct posix_acl	*acl_default;
+	struct kstat		stat;
+};
+
+struct nfsd3_setaclargs {
+	struct svc_fh		fh;
+	__u32			mask;
+	struct posix_acl	*acl_access;
+	struct posix_acl	*acl_default;
+};
+
+struct nfsd3_attrstat {
+	__be32			status;
+	struct svc_fh		fh;
+	struct kstat            stat;
+};
+
+/* Helper functions for NFSv3 ACL code */
+bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
+bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
+bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
+				const struct svc_fh *fhp);
+
 static __be32 nfsd3_map_status(__be32 status)
 {
 	switch (status) {
Signature · 1 line
2.56.0
author maintainer
#4 lore raw

PATCH 4/13 NFSD: New NFS_ACLv3 status codes

In reply to Chuck Lever

In preparation for converting the NFS_ACLv3 procedures to use generated XDR decoding and encoding, swap in the generated headers, replace the usage of the conventional nfserr codes with the RPC protocol-specified ACL3ERR constants.

Note that this conversion still depends on the numeric equivalence of the NFSv3 and NFS_ACLv3 status codes.

nfsd3_map_errno() keeps the errno choices nfserrno() makes for the errors that aclstat3 can express, including the filesystem corruption errnos that map to ACL3ERR_IO and the transient ones that map to ACL3ERR_JUKEBOX. Every other errno becomes ACL3ERR_SERVERFAULT.

The NFS_ACL bit mask symbolic constants are replaced as well so that this TU continues to compile with the header generated from the RPC spec.

---
 Documentation/sunrpc/xdr/nfs_acl3.x    |  1 +
 fs/nfsd/nfs3acl.c                      | 99 +++++++++++++++++++-------
 fs/nfsd/nfs_acl3xdr_gen.c              | 22 +++---
 fs/nfsd/nfs_acl3xdr_gen.h              |  2 +-
 include/linux/sunrpc/xdrgen/nfs_acl3.h |  4 +-
 5 files changed, 90 insertions(+), 38 deletions(-)
Documentation/sunrpc/xdr/nfs_acl3.x +1 -0
index b0e1d2e1fd43..b355705bf970 100644
@@ -189,6 +189,7 @@ enum aclstat3 {
     ACL3ERR_SERVERFAULT = 10006,
     ACL3ERR_JUKEBOX = 10008
 };
+pragma big_endian aclstat3;
 
 /*
  * NFS_ACL version 3 procedure arguments and results
fs/nfsd/nfs3acl.c +74 -25

194 lines not on this page · raw message

fs/nfsd/nfs_acl3xdr_gen.c +12 -10
index 5bdeb29addfe..05e35653a0fc 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 // Generated by xdrgen. Manual edits will be lost.
 // XDR specification file: ../../Documentation/sunrpc/xdr/nfs_acl3.x
-// XDR specification modification time: Fri Jul 10 20:10:15 2026
+// XDR specification modification time: Fri Jul 10 20:12:08 2026
 
 #include <linux/sunrpc/svc.h>
 
@@ -198,10 +198,12 @@ xdrgen_decode_post_op_attr(struct xdr_stream *xdr, struct post_op_attr *ptr)
 static bool __maybe_unused
 xdrgen_decode_aclstat3(struct xdr_stream *xdr, aclstat3 *ptr)
 {
+	__be32 raw;
 	u32 val;
 
-	if (xdr_stream_decode_u32(xdr, &val) < 0)
+	if (xdr_stream_decode_be32(xdr, &raw) < 0)
 		return false;
+	val = be32_to_cpu(raw);
 	/* Compiler may optimize to a range check for dense enums */
 	switch (val) {
 	case ACL3_OK:
@@ -222,7 +224,7 @@ xdrgen_decode_aclstat3(struct xdr_stream *xdr, aclstat3 *ptr)
 	default:
 		return false;
 	}
-	*ptr = val;
+	*ptr = raw;
 	return true;
 }
 
@@ -260,7 +262,7 @@ xdrgen_decode_GETACL3res(struct xdr_stream *xdr, struct GETACL3res *ptr)
 	if (!xdrgen_decode_aclstat3(xdr, &ptr->status))
 		return false;
 	switch (ptr->status) {
-	case ACL3_OK:
+	case __constant_cpu_to_be32(ACL3_OK):
 		if (!xdrgen_decode_GETACL3resok(xdr, &ptr->u.resok))
 			return false;
 		break;
@@ -303,7 +305,7 @@ xdrgen_decode_SETACL3res(struct xdr_stream *xdr, struct SETACL3res *ptr)
 	if (!xdrgen_decode_aclstat3(xdr, &ptr->status))
 		return false;
 	switch (ptr->status) {
-	case ACL3_OK:
+	case __constant_cpu_to_be32(ACL3_OK):
 		if (!xdrgen_decode_SETACL3resok(xdr, &ptr->u.resok))
 			return false;
 		break;
@@ -340,7 +342,7 @@ xdrgen_decode_GETXATTRDIR3res(struct xdr_stream *xdr, struct GETXATTRDIR3res *pt
 	if (!xdrgen_decode_aclstat3(xdr, &ptr->status))
 		return false;
 	switch (ptr->status) {
-	case ACL3_OK:
+	case __constant_cpu_to_be32(ACL3_OK):
 		if (!xdrgen_decode_GETXATTRDIR3resok(xdr, &ptr->u.resok))
 			return false;
 		break;
@@ -573,7 +575,7 @@ xdrgen_encode_post_op_attr(struct xdr_stream *xdr, const struct post_op_attr *pt
 static bool __maybe_unused
 xdrgen_encode_aclstat3(struct xdr_stream *xdr, aclstat3 value)
 {
-	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
+	return xdr_stream_encode_be32(xdr, value) == XDR_UNIT;
 }
 
 static bool __maybe_unused
@@ -610,7 +612,7 @@ xdrgen_encode_GETACL3res(struct xdr_stream *xdr, const struct GETACL3res *ptr)
 	if (!xdrgen_encode_aclstat3(xdr, ptr->status))
 		return false;
 	switch (ptr->status) {
-	case ACL3_OK:
+	case __constant_cpu_to_be32(ACL3_OK):
 		if (!xdrgen_encode_GETACL3resok(xdr, &ptr->u.resok))
 			return false;
 		break;
@@ -653,7 +655,7 @@ xdrgen_encode_SETACL3res(struct xdr_stream *xdr, const struct SETACL3res *ptr)
 	if (!xdrgen_encode_aclstat3(xdr, ptr->status))
 		return false;
 	switch (ptr->status) {
-	case ACL3_OK:
+	case __constant_cpu_to_be32(ACL3_OK):
 		if (!xdrgen_encode_SETACL3resok(xdr, &ptr->u.resok))
 			return false;
 		break;
@@ -690,7 +692,7 @@ xdrgen_encode_GETXATTRDIR3res(struct xdr_stream *xdr, const struct GETXATTRDIR3r
 	if (!xdrgen_encode_aclstat3(xdr, ptr->status))
 		return false;
 	switch (ptr->status) {
-	case ACL3_OK:
+	case __constant_cpu_to_be32(ACL3_OK):
 		if (!xdrgen_encode_GETXATTRDIR3resok(xdr, &ptr->u.resok))
 			return false;
 		break;
fs/nfsd/nfs_acl3xdr_gen.h +1 -1
index d778004ba26a..8d960c0506db 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Generated by xdrgen. Manual edits will be lost. */
 /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs_acl3.x */
-/* XDR specification modification time: Fri Jul 10 20:10:15 2026 */
+/* XDR specification modification time: Fri Jul 10 20:12:08 2026 */
 
 #ifndef _LINUX_XDRGEN_NFS_ACL3_DECL_H
 #define _LINUX_XDRGEN_NFS_ACL3_DECL_H
include/linux/sunrpc/xdrgen/nfs_acl3.h +2 -2
index 8758450dbca0..4d71e4907261 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Generated by xdrgen. Manual edits will be lost. */
 /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs_acl3.x */
-/* XDR specification modification time: Fri Jul 10 20:10:15 2026 */
+/* XDR specification modification time: Fri Jul 10 20:12:08 2026 */
 
 #ifndef _LINUX_XDRGEN_NFS_ACL3_DEF_H
 #define _LINUX_XDRGEN_NFS_ACL3_DEF_H
@@ -149,7 +149,7 @@ enum aclstat3 {
 	ACL3ERR_JUKEBOX = 10008,
 };
 
-typedef enum aclstat3 aclstat3;
+typedef __be32 aclstat3;
 
 struct GETACL3args {
 	struct nfs_fh3 fh;
Signature · 1 line
2.56.0
author maintainer
#5 lore raw

PATCH 5/13 NFSD: Use xdrgen XDR functions for the NFS-ACL v3 NULL procedure

In reply to Chuck Lever

Hand-written XDR encoders and decoders are difficult to maintain and can diverge from protocol specifications. Migrating to xdrgen-generated code improves type safety and ensures the implementation matches the NFS_ACL version 3 protocol description exactly.

Convert the NULL procedure to xdrgen_svc_decode_void and xdrgen_svc_encode_void. NULL has no arguments or results, so it is the first procedure converted and needs only the generic void codecs, not the generated NFS_ACLv3 header. GETACL and SETACL remain hand-rolled until subsequent patches.

NULL returns no XDR-encoded data, so pc_xdrressize is set to XDR_void. The argzero field is also set to zero since xdrgen decoders initialize all decoded values.

---
 fs/nfsd/nfs3acl.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
fs/nfsd/nfs3acl.c +16 -10
index 536593ba59bc..048046af15c0 100644
@@ -110,11 +110,17 @@ static __be32 nfsd3_map_status(__be32 status)
 	return status;
 }
 
-/*
- * NULL call.
+/**
+ * nfsd3_proc_null - NULL: Do nothing
+ * @rqstp: RPC transaction context
+ *
+ * Return:
+ *   %rpc_success:		RPC executed successfully
+ *
+ * RPC synopsis:
+ *   void ACLPROC3_NULL(void) = 0;
  */
-static __be32
-nfsd3_proc_null(struct svc_rqst *rqstp)
+static __be32 nfsd3_proc_null(struct svc_rqst *rqstp)
 {
 	return rpc_success;
 }
@@ -342,13 +348,13 @@ static void nfs3svc_release_setacl(struct svc_rqst *rqstp)
 static const struct svc_procedure nfsd_acl_procedures3[3] = {
 	[ACLPROC3_NULL] = {
 		.pc_func = nfsd3_proc_null,
-		.pc_decode = nfssvc_decode_voidarg,
-		.pc_encode = nfssvc_encode_voidres,
-		.pc_argsize = sizeof(struct nfsd_voidargs),
-		.pc_argzero = sizeof(struct nfsd_voidargs),
-		.pc_ressize = sizeof(struct nfsd_voidres),
+		.pc_decode = xdrgen_svc_decode_void,
+		.pc_encode = xdrgen_svc_encode_void,
+		.pc_argsize = XDR_void,
+		.pc_argzero = 0,
+		.pc_ressize = 0,
 		.pc_cachetype = RC_NOCACHE,
-		.pc_xdrressize = ST,
+		.pc_xdrressize = XDR_void,
 		.pc_name = "NULL",
 	},
 	[ACLPROC3_GETACL] = {
Signature · 1 line
2.56.0
author maintainer
#6 lore raw

PATCH 6/13 NFSD: Implement NFS-ACL v3 ACL encoding and decoding with xdrgen

In reply to Chuck Lever

The NFS-ACL v3 GETACL result encoder and SETACL argument decoder cannot be generated the way the other procedures' codecs are: the wire secattr is a Solaris projection of the kernel's struct posix_acl, and the per-entry transformation between them -- tag and id mapping, the canonical four-entry expansion that Solaris VxFS interoperability requires, and counts gated by the request mask -- is application logic that xdrgen cannot synthesize. Keeping those two codecs hand-rolled would force the generated NFSv3 types they call, nfs_fh3, fattr3, and post_op_attr, to keep external linkage, and those symbols would collide at link time with the public definitions that nfs3xdr_gen.c already emits for NFSv3 proper.

Supply the nfsd side of xdrgen's hook-driven aggregate codec mechanism. "pragma aggregate" markers on secattr's two aclent<> members select the streaming codec, whose generated framing owns the wire representation and drives per-element application hooks. The hooks hold the posix_acl logic factored from nfs_stream_encode_acl() and nfs_stream_decode_acl(); both arrays share one hook set, with the cursor's member_id distinguishing the access list from the default list. Wrapper structures pair each generated argument or result type with the legacy application state (svc_fh, posix_acl pointers, kstat), placing the generated type at offset zero so rq_argp or rq_resp addresses both the generated type the codec fills and the wrapper the hooks read. The hooks reach that wrapper by way of the svc_rqst, which svcxdr_init_decode() and svcxdr_init_encode() leave in the xdr_stream's application-private pointer.

On decode, the begin hook validates the declared count and the request mask, allocates the posix_acl at its known size, and publishes it into the argument wrapper before any fallible per-entry decode runs, so a mid-list failure leaves the ACL reachable by pc_release rather than leaked. A zero-length published default list stays NULL, which set_posix_acl() treats as ACL removal.

A well-formed request that is nonetheless invalid -- an undefined request mask bit, an empty access ACL, a perm bit outside rwx, an undefined entry type, a user or group id with no kernel mapping, a list whose declared count differs from its length, or more entries than NFS_ACL_MAX_ENTRIES -- instead marks the argument wrapper and lets the decode succeed, so nfsd3_proc_setacl() can report ACL3ERR_INVAL rather than GARBAGE_ARGS (draft-ietf-nfsv4-nfs-acl Section 3.4.4.2). The pre-conversion decoder rejected most of these cases with GARBAGE_ARGS. It accepted an empty access ACL as a request to remove the object's access ACL, an operation the protocol does not define, and it cleared perm bits outside rwx in an NA_CLASS_OBJ entry without complaint because Solaris clients were seen to set them. The draft makes both invalid, so the NFS_ACLv3 server now reports ACL3ERR_INVAL for them as well. These are deliberate, minor changes to the SETACL wire behavior.

Because the containing codecs are fully generated, the NFSv3 types the ACL specification re-declares stay static in nfs_acl3xdr_gen.c, and no public pragma is needed.

Subsequent patches convert the GETACL and SETACL procedures to the generated codecs.

---
 Documentation/sunrpc/xdr/nfs_acl3.x    |   2 +
 fs/nfsd/nfs3acl.c                      | 271 +++++++++++++++++++++++++
 fs/nfsd/nfs_acl3xdr_gen.c              | 138 ++++++++++---
 fs/nfsd/nfs_acl3xdr_gen.h              |  14 +-
 include/linux/sunrpc/xdrgen/nfs_acl3.h |   2 +-
 5 files changed, 400 insertions(+), 27 deletions(-)
Documentation/sunrpc/xdr/nfs_acl3.x +2 -0
index b355705bf970..931a7d629603 100644
@@ -91,6 +91,8 @@ struct secattr {
     int dfaclcnt;
     aclent dfaclent<NFS_ACL_MAX_ENTRIES>;
 };
+pragma aggregate secattr aclent;
+pragma aggregate secattr dfaclent;
 
 /*
  * The values for the mask element of the secattr struct as well
fs/nfsd/nfs3acl.c +271 -0

289 lines not on this page · raw message

fs/nfsd/nfs_acl3xdr_gen.c +113 -25

164 lines not on this page · raw message

fs/nfsd/nfs_acl3xdr_gen.h +13 -1
index 8d960c0506db..629a06566ca7 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Generated by xdrgen. Manual edits will be lost. */
 /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs_acl3.x */
-/* XDR specification modification time: Fri Jul 10 20:12:08 2026 */
+/* XDR specification modification time: Fri Jul 10 20:12:44 2026 */
 
 #ifndef _LINUX_XDRGEN_NFS_ACL3_DECL_H
 #define _LINUX_XDRGEN_NFS_ACL3_DECL_H
@@ -13,6 +13,18 @@
 #include <linux/sunrpc/xdrgen/_builtins.h>
 #include <linux/sunrpc/xdrgen/nfs_acl3.h>
 
+enum {
+	NFS_ACL3_SECATTR_ACLENT,
+	NFS_ACL3_SECATTR_DFACLENT,
+};
+
+bool nfs_acl3_secattr_encode_begin(struct xdrgen_aggregate_cursor *c);
+bool nfs_acl3_secattr_encode(struct xdrgen_aggregate_cursor *c, struct aclent *out);
+bool nfs_acl3_secattr_encode_end(struct xdrgen_aggregate_cursor *c, bool ok);
+bool nfs_acl3_secattr_decode_begin(struct xdrgen_aggregate_cursor *c);
+bool nfs_acl3_secattr_decode(struct xdrgen_aggregate_cursor *c, const struct aclent *in);
+bool nfs_acl3_secattr_decode_end(struct xdrgen_aggregate_cursor *c, bool ok);
+
 bool nfs_acl_svc_decode_GETACL3args(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nfs_acl_svc_decode_SETACL3args(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nfs_acl_svc_decode_GETXATTRDIR3args(struct svc_rqst *rqstp, struct xdr_stream *xdr);
include/linux/sunrpc/xdrgen/nfs_acl3.h +1 -1
index 4d71e4907261..92c0d1e0b0a8 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Generated by xdrgen. Manual edits will be lost. */
 /* XDR specification file: ../../Documentation/sunrpc/xdr/nfs_acl3.x */
-/* XDR specification modification time: Fri Jul 10 20:12:08 2026 */
+/* XDR specification modification time: Fri Jul 10 20:12:44 2026 */
 
 #ifndef _LINUX_XDRGEN_NFS_ACL3_DEF_H
 #define _LINUX_XDRGEN_NFS_ACL3_DEF_H
Signature · 1 line
2.56.0
author maintainer
#7 lore raw

PATCH 7/13 NFSD: Use xdrgen XDR functions for the NFS-ACL v3 GETACL procedure

In reply to Chuck Lever

Continue migrating nfs3acl.c off its hand-written codecs. GETACL3res encode carries a secattr, a post_op_attr, and an aclstat3 status, none of which the hand-rolled path expresses in a form xdrgen can check against the protocol description.

Convert GETACL to the generated codec. The preceding patch installed the secattr aggregate hooks and the argument and result wrappers, so the proc fills only the scalar secattr fields -- the request mask and the two entry counts -- and the generated encoder streams the ACL entries from the proc's posix_acls through those hooks. The GETACL3args and GETACL3res wrappers carry the svc_fh and posix_acl state the NFSD VFS layer still uses alongside the generated types.

The NFSv3 file handle is variable-length, so the proc rejects an unparseable handle as ACL3ERR_BADHANDLE before acquiring any resources. The procedure fills the post_op_attr, records the inode's owner ids, and fetches the ACLs while the file handle is verified, then releases the file handle itself. When the file handle carries fh_no_wcc or the attribute fetch fails, the post_op_attr stays absent and the ACL is still returned, as the hand-rolled encoder left it. The encoder reads the ACL owner ids from the recorded owner rather than from a live inode, so nfs3svc_release_getacl() shrinks to the two posix_acl_release() calls; those releases must stay a release-time job because the encoder still consumes the posix_acls after the reply is built.

Filling the fattr3 masks the mode with S_IALLUGO and reuses the fsid and timestamp handling the native NFSv3 attribute encoder already applies.

---
 fs/nfsd/nfs3acl.c | 282 +++++++++++++++++++++++++++-------------------
 1 file changed, 166 insertions(+), 116 deletions(-)
fs/nfsd/nfs3acl.c +166 -116
index 1fb9d265bc03..beb51b9dc2f1 100644
@@ -7,6 +7,7 @@
 
 #include <linux/gfp.h>
 #include <linux/fs.h>
+#include <linux/filelock.h>
 #include <linux/nfsacl.h>
 #include <linux/nfs4.h>
 
@@ -14,10 +15,19 @@
 
 #include "cache.h"
 #include "nfsd.h"
+#include "auth.h"
 #include "vfs.h"
 
 #define NFS_ACL_MASK		(NA_ACL | NA_ACLCNT | NA_DFACL | NA_DFACLCNT)
 
+/*
+ * The generated <linux/sunrpc/xdrgen/nfs_acl3.h> defines the NFSv3
+ * inherited types (nfs_fh3, fattr3, post_op_attr, ...), so the native
+ * NFSv3 headers that also define them cannot be included here. Define
+ * the one inherited NFSv3 constant needed for symlink size clamping.
+ */
+#define NFS3_MAXPATHLEN		PATH_MAX
+
 /*
  * Wrapper structures combine xdrgen types with legacy structures.
  * The xdrgen field must be first so the structure can be cast
@@ -30,15 +40,13 @@ struct GETACL3args_wrapper {
 
 static_assert(offsetof(struct GETACL3args_wrapper, xdrgen) == 0);
 
-/*
- * The ACL is encoded from the posix_acl fields below, so the
- * generated secattr (xdrgen.u.resok.acl) is left unused.
- */
 struct GETACL3res_wrapper {
 	struct GETACL3res	xdrgen;
 	int			mask;
 	struct posix_acl	*acl_access;
 	struct posix_acl	*acl_default;
+	kuid_t			uid;
+	kgid_t			gid;
 	struct kstat		stat;
 };
 
@@ -64,39 +72,6 @@ struct SETACL3args_wrapper {
 
 static_assert(offsetof(struct SETACL3args_wrapper, xdrgen) == 0);
 
-struct nfsd3_getaclargs {
-	struct svc_fh		fh;
-	__u32			mask;
-};
-
-struct nfsd3_getaclres {
-	__be32			status;
-	struct svc_fh		fh;
-	int			mask;
-	struct posix_acl	*acl_access;
-	struct posix_acl	*acl_default;
-	struct kstat		stat;
-};
-
-struct nfsd3_setaclargs {
-	struct svc_fh		fh;
-	__u32			mask;
-	struct posix_acl	*acl_access;
-	struct posix_acl	*acl_default;
-};
-
-struct nfsd3_attrstat {
-	__be32			status;
-	struct svc_fh		fh;
-	struct kstat            stat;
-};
-
-/* Helper functions for NFSv3 ACL code */
-bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
-bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
-bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-				const struct svc_fh *fhp);
-
 enum {
 	acl3_ok = __constant_cpu_to_be32(ACL3_OK),
 	acl3err_perm = __constant_cpu_to_be32(ACL3ERR_PERM),
@@ -156,6 +131,103 @@ static __be32 nfsd3_map_status(__be32 status)
 	return status;
 }
 
+/* Legacy structures for the hand-rolled SETACL codec. */
+struct nfsd3_setaclargs {
+	struct svc_fh		fh;
+	__u32			mask;
+	struct posix_acl	*acl_access;
+	struct posix_acl	*acl_default;
+};
+
+struct nfsd3_attrstat {
+	__be32			status;
+	struct svc_fh		fh;
+	struct kstat            stat;
+};
+
+/* Helper functions for NFSv3 ACL code */
+bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
+bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
+bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
+				const struct svc_fh *fhp);
+
+static bool
+nfs3acl_decode_fh(const struct nfs_fh3 *fh, struct svc_fh *fhp)
+{
+	if (fh->data.len == 0 || fh->data.len > NFS3_FHSIZE)
+		return false;
+	fh_init(fhp, NFS3_FHSIZE);
+	fhp->fh_handle.fh_size = fh->data.len;
+	memcpy(&fhp->fh_handle.fh_raw, fh->data.data, fh->data.len);
+	return true;
+}
+
+static u32
+nfs3acl_mode_to_ftype3(umode_t mode)
+{
+	switch (mode & S_IFMT) {
+	case S_IFREG:  return NF3REG;
+	case S_IFDIR:  return NF3DIR;
+	case S_IFBLK:  return NF3BLK;
+	case S_IFCHR:  return NF3CHR;
+	case S_IFLNK:  return NF3LNK;
+	case S_IFSOCK: return NF3SOCK;
+	case S_IFIFO:  return NF3FIFO;
+	}
+	return NF3REG;
+}
+
+static void
+nfs3acl_stat_to_fattr3(struct svc_rqst *rqstp, struct fattr3 *fattr,
+		       const struct kstat *stat, const struct svc_fh *fhp)
+{
+	struct user_namespace *userns = nfsd_user_namespace(rqstp);
+	u64 fsid;
+
+	fattr->type = nfs3acl_mode_to_ftype3(stat->mode);
+	fattr->mode = stat->mode & S_IALLUGO;
+	fattr->nlink = stat->nlink;
+	fattr->uid = from_kuid_munged(userns, stat->uid);
+	fattr->gid = from_kgid_munged(userns, stat->gid);
+	if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN)
+		fattr->size = NFS3_MAXPATHLEN;
+	else
+		fattr->size = stat->size;
+	fattr->used = (u64)stat->blocks << 9;
+	fattr->rdev.specdata1 = MAJOR(stat->rdev);
+	fattr->rdev.specdata2 = MINOR(stat->rdev);
+
+	switch (fsid_source(fhp)) {
+	case FSIDSOURCE_FSID:
+		fsid = (u64)fhp->fh_export->ex_fsid;
+		break;
+	case FSIDSOURCE_UUID:
+		fsid = ((u64 *)fhp->fh_export->ex_uuid)[0];
+		fsid ^= ((u64 *)fhp->fh_export->ex_uuid)[1];
+		break;
+	default:
+		fsid = (u64)huge_encode_dev(fhp->fh_dentry->d_sb->s_dev);
+	}
+	fattr->fsid = fsid;
+	fattr->fileid = stat->ino;
+
+	fattr->atime.seconds = stat->atime.tv_sec;
+	fattr->atime.nseconds = stat->atime.tv_nsec;
+	fattr->mtime.seconds = stat->mtime.tv_sec;
+	fattr->mtime.nseconds = stat->mtime.tv_nsec;
+	fattr->ctime.seconds = stat->ctime.tv_sec;
+	fattr->ctime.nseconds = stat->ctime.tv_nsec;
+}
+
+static void
+nfs3acl_encode_post_op_attr(struct svc_rqst *rqstp, struct post_op_attr *attr,
+			    struct kstat *stat, const struct svc_fh *fhp)
+{
+	attr->attributes_follow = true;
+	lease_get_mtime(d_inode(fhp->fh_dentry), &stat->mtime);
+	nfs3acl_stat_to_fattr3(rqstp, &attr->u.attributes, stat, fhp);
+}
+
 /*
  * A minimal (three-entry) ACL travels as four wire entries: the
  * POSIX entries plus a synthesized NA_CLASS_OBJ mask. The wire
@@ -184,29 +256,48 @@ static __be32 nfsd3_proc_null(struct svc_rqst *rqstp)
 	return rpc_success;
 }
 
-/*
- * Get the Access and/or Default ACL of a file.
+/**
+ * nfsd3_proc_getacl - GETACL: Get the Access and/or Default ACL of a file
+ * @rqstp: RPC transaction context
+ *
+ * Return:
+ *   %rpc_success:		RPC executed successfully
+ *
+ * RPC synopsis:
+ *   GETACL3res ACLPROC3_GETACL(GETACL3args) = 1;
  */
 static __be32 nfsd3_proc_getacl(struct svc_rqst *rqstp)
 {
-	struct nfsd3_getaclargs *argp = rqstp->rq_argp;
-	struct nfsd3_getaclres *resp = rqstp->rq_resp;
+	struct GETACL3args_wrapper *argp = rqstp->rq_argp;
+	struct GETACL3res_wrapper *resp = rqstp->rq_resp;
+	struct svc_fh *fhp = &argp->fh;
 	struct posix_acl *acl;
 	struct inode *inode;
-	svc_fh *fh;
 
-	fh = fh_copy(&resp->fh, &argp->fh);
-	resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
-	if (resp->status != acl3_ok)
+	resp->xdrgen.u.resok.attr.attributes_follow = false;
+
+	/* An unparsable handle leaves @fhp uninitialized, so skip fh_put. */
+	if (!nfs3acl_decode_fh(&argp->xdrgen.fh, fhp)) {
+		resp->xdrgen.status = acl3err_badhandle;
+		return rpc_success;
+	}
+
+	resp->xdrgen.status = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
+	if (resp->xdrgen.status != acl3_ok)
 		goto out;
+	inode = d_inode(fhp->fh_dentry);
 
-	inode = d_inode(fh->fh_dentry);
+	if (!fhp->fh_no_wcc && fh_getattr(fhp, &resp->stat) == acl3_ok)
+		nfs3acl_encode_post_op_attr(rqstp, &resp->xdrgen.u.resok.attr,
+					    &resp->stat, fhp);
 
-	if (argp->mask & ~NFS_ACL_MASK) {
-		resp->status = acl3err_inval;
+	if (argp->xdrgen.mask & ~NFS_ACL_MASK) {
+		resp->xdrgen.status = acl3err_inval;
 		goto out;
 	}
-	resp->mask = argp->mask;
+	resp->mask = argp->xdrgen.mask;
+	resp->uid = inode->i_uid;
+	resp->gid = inode->i_gid;
 
 	if (resp->mask & (NA_ACL | NA_ACLCNT)) {
 		acl = get_inode_acl(inode, ACL_TYPE_ACCESS);
@@ -215,25 +306,34 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst *rqstp)
 			acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
 		}
 		if (IS_ERR(acl)) {
-			resp->status = nfsd3_map_errno(PTR_ERR(acl));
+			resp->xdrgen.status = nfsd3_map_errno(PTR_ERR(acl));
 			goto fail;
 		}
 		resp->acl_access = acl;
 	}
 	if (resp->mask & (NA_DFACL | NA_DFACLCNT)) {
-		/* Check how Solaris handles requests for the Default ACL
-		   of a non-directory! */
 		acl = get_inode_acl(inode, ACL_TYPE_DEFAULT);
 		if (IS_ERR(acl)) {
-			resp->status = nfsd3_map_errno(PTR_ERR(acl));
+			resp->xdrgen.status = nfsd3_map_errno(PTR_ERR(acl));
 			goto fail;
 		}
 		resp->acl_default = acl;
 	}
 
-	/* resp->acl_{access,default} are released in nfs3svc_release_getacl. */
+	/*
+	 * The generated secattr encoder streams the ACL entries from
+	 * the posix_acls above via the encode hooks; the proc supplies
+	 * the scalar fields.  aclcnt/dfaclcnt carry the entry count
+	 * independent of whether the matching list is requested.
+	 */
+	resp->xdrgen.u.resok.acl.mask = resp->mask;
+	resp->xdrgen.u.resok.acl.aclcnt = nfs3acl_acl_entries(resp->acl_access);
+	resp->xdrgen.u.resok.acl.dfaclcnt = nfs3acl_acl_entries(resp->acl_default);
+
 out:
-	resp->status = nfsd3_map_status(resp->status);
+	/* resp->acl_{access,default} are released in nfs3svc_release_getacl. */
+	fh_put(fhp);
+	resp->xdrgen.status = nfsd3_map_status(resp->xdrgen.status);
 	return rpc_success;
 
 fail:
@@ -295,19 +395,6 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst *rqstp)
  * XDR decode functions
  */
 
-static bool
-nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	struct nfsd3_getaclargs *args = rqstp->rq_argp;
-
-	if (!svcxdr_decode_nfs_fh3(xdr, &args->fh))
-		return false;
-	if (xdr_stream_decode_u32(xdr, &args->mask) < 0)
-		return false;
-
-	return true;
-}
-
 static bool
 nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 {
@@ -333,40 +420,6 @@ nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
  * XDR encode functions
  */
 
-/* GETACL */
-static bool
-nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	struct nfsd3_getaclres *resp = rqstp->rq_resp;
-	struct dentry *dentry = resp->fh.fh_dentry;
-	struct inode *inode;
-
-	if (!svcxdr_encode_nfsstat3(xdr, resp->status))
-		return false;
-	switch (resp->status) {
-	case acl3_ok:
-		inode = d_inode(dentry);
-		if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
-			return false;
-		if (xdr_stream_encode_u32(xdr, resp->mask) < 0)
-			return false;
-
-		if (!nfs_stream_encode_acl(xdr, inode, resp->acl_access,
-					   resp->mask & NA_ACL, 0))
-			return false;
-		if (!nfs_stream_encode_acl(xdr, inode, resp->acl_default,
-					   resp->mask & NA_DFACL,
-					   NA_ACL_DEFAULT))
-			return false;
-		break;
-	default:
-		if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
-			return false;
-	}
-
-	return true;
-}
-
 /* SETACL */
 static bool
 nfs3svc_encode_setaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
@@ -433,10 +486,10 @@ bool nfs_acl3_secattr_encode(struct xdrgen_aggregate_cursor *c,
 	out->type = tag | typeflag;
 	switch (tag) {
 	case ACL_USER_OBJ:
-		out->id = from_kuid(&init_user_ns, resp->stat.uid);
+		out->id = from_kuid(&init_user_ns, resp->uid);
 		break;
 	case ACL_GROUP_OBJ:
-		out->id = from_kgid(&init_user_ns, resp->stat.gid);
+		out->id = from_kgid(&init_user_ns, resp->gid);
 		break;
 	case ACL_USER:
 		out->id = from_kuid(&init_user_ns, entry->e_uid);
@@ -594,9 +647,8 @@ bool nfs_acl3_secattr_decode_end(struct xdrgen_aggregate_cursor *c, bool ok)
  */
 static void nfs3svc_release_getacl(struct svc_rqst *rqstp)
 {
-	struct nfsd3_getaclres *resp = rqstp->rq_resp;
+	struct GETACL3res_wrapper *resp = rqstp->rq_resp;
 
-	fh_put(&resp->fh);
 	posix_acl_release(resp->acl_access);
 	posix_acl_release(resp->acl_default);
 }
@@ -614,7 +666,6 @@ static void nfs3svc_release_setacl(struct svc_rqst *rqstp)
 #define ST 1		/* status*/
 #define AT 21		/* attributes */
 #define pAT (1+AT)	/* post attributes - conditional */
-#define ACL (1+NFS_ACL_MAX_ENTRIES*3)  /* Access Control List */
 
 static const struct svc_procedure nfsd_acl_procedures3[3] = {
 	[ACLPROC3_NULL] = {
@@ -630,14 +681,14 @@ static const struct svc_procedure nfsd_acl_procedures3[3] = {
 	},
 	[ACLPROC3_GETACL] = {
 		.pc_func = nfsd3_proc_getacl,
-		.pc_decode = nfs3svc_decode_getaclargs,
-		.pc_encode = nfs3svc_encode_getaclres,
+		.pc_decode = nfs_acl_svc_decode_GETACL3args,
+		.pc_encode = nfs_acl_svc_encode_GETACL3res,
 		.pc_release = nfs3svc_release_getacl,
-		.pc_argsize = sizeof(struct nfsd3_getaclargs),
-		.pc_argzero = sizeof(struct nfsd3_getaclargs),
-		.pc_ressize = sizeof(struct nfsd3_getaclres),
+		.pc_argsize = sizeof(struct GETACL3args_wrapper),
+		.pc_argzero = 0,
+		.pc_ressize = sizeof(struct GETACL3res_wrapper),
 		.pc_cachetype = RC_NOCACHE,
-		.pc_xdrressize = ST+1+2*(1+ACL),
+		.pc_xdrressize = NFS_ACL3_GETACL3res_sz,
 		.pc_name = "GETACL",
 	},
 	[ACLPROC3_SETACL] = {
@@ -658,9 +709,9 @@ static const struct svc_procedure nfsd_acl_procedures3[3] = {
  * Storage requirements for XDR arguments and results.
  */
 union nfsd_acl3_xdrstore {
-	struct nfsd3_getaclargs		getaclargs;
+	struct GETACL3args_wrapper	getaclargs;
 	struct nfsd3_setaclargs		setaclargs;
-	struct nfsd3_getaclres		getaclres;
+	struct GETACL3res_wrapper	getaclres;
 	struct nfsd3_attrstat		attrstat;
 };
 
@@ -671,4 +722,3 @@ const struct svc_version nfsd_acl_version3 = {
 	.vs_dispatch	= nfsd_dispatch,
 	.vs_xdrsize	= sizeof(union nfsd_acl3_xdrstore),
 };
-
Signature · 1 line
2.56.0
author maintainer
#8 lore raw

PATCH 8/13 NFSD: Use xdrgen XDR functions for the NFS-ACL v3 SETACL procedure

In reply to Chuck Lever

SETACL3args decode and SETACL3res encode are the last hand-rolled NFS_ACLv3 codecs. The previous patch already defined the secattr decode hooks that the generated SETACL3args decoder drives, so the conversion is now a matter of wiring the procedure to the generated entry points.

Convert SETACL to the generated codec. The decode hooks publish each posix_acl into the argument wrapper as it is allocated; a zero-length default list publishes a NULL posix_acl for ACL removal. When the decoder has marked the argument ACL invalid (see the codec patch), the procedure reports ACL3ERR_INVAL once the handle is verified and does nothing else, so a stale handle or a refused export still takes precedence over a bad ACL. A default ACL presented for an object that is not a directory is reported as ACL3ERR_INVAL at the same point, where set_posix_acl() would have reported EACCES; draft-ietf-nfsv4-nfs-acl Section 3.4.4.2 lists that case among the invalid ACLs. SETACL3args
therefore zeroes its whole argument wrapper through pc_argzero so both ACL pointers and the "invalid" flag start clear and pc_release reaps a partially decoded request with no leak and no double free.

Both arms of SETACL3res open with a post_op_attr, so the proc fills the attributes for the reply whether or not the operation succeeded, as the hand-rolled encoder did. A failed attribute fetch leaves the post_op_attr absent; it does not turn a SETACL that has already been applied into a failure. With SETACL generated, the hand-rolled setacl codecs, the legacy argument and result structures, and the svcxdr helper declarations they relied on are all removed.

---
 fs/nfsd/nfs3acl.c | 174 ++++++++++++++++++++--------------------------
 1 file changed, 76 insertions(+), 98 deletions(-)
fs/nfsd/nfs3acl.c +76 -98
index beb51b9dc2f1..19f5a6127673 100644
@@ -52,10 +52,6 @@ struct GETACL3res_wrapper {
 
 static_assert(offsetof(struct GETACL3res_wrapper, xdrgen) == 0);
 
-/*
- * The ACLs are decoded by hand into the posix_acl fields below, so
- * the generated aclent arrays (xdrgen.acl) are left unused.
- */
 struct SETACL3args_wrapper {
 	struct SETACL3args	xdrgen;
 	struct svc_fh		fh;
@@ -72,6 +68,13 @@ struct SETACL3args_wrapper {
 
 static_assert(offsetof(struct SETACL3args_wrapper, xdrgen) == 0);
 
+struct SETACL3res_wrapper {
+	struct SETACL3res	xdrgen;
+	struct kstat		stat;
+};
+
+static_assert(offsetof(struct SETACL3res_wrapper, xdrgen) == 0);
+
 enum {
 	acl3_ok = __constant_cpu_to_be32(ACL3_OK),
 	acl3err_perm = __constant_cpu_to_be32(ACL3ERR_PERM),
@@ -131,26 +134,6 @@ static __be32 nfsd3_map_status(__be32 status)
 	return status;
 }
 
-/* Legacy structures for the hand-rolled SETACL codec. */
-struct nfsd3_setaclargs {
-	struct svc_fh		fh;
-	__u32			mask;
-	struct posix_acl	*acl_access;
-	struct posix_acl	*acl_default;
-};
-
-struct nfsd3_attrstat {
-	__be32			status;
-	struct svc_fh		fh;
-	struct kstat            stat;
-};
-
-/* Helper functions for NFSv3 ACL code */
-bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
-bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
-bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-				const struct svc_fh *fhp);
-
 static bool
 nfs3acl_decode_fh(const struct nfs_fh3 *fh, struct svc_fh *fhp)
 {
@@ -344,90 +327,91 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst *rqstp)
 	goto out;
 }
 
-/*
- * Set the Access and/or Default ACL of a file.
+/**
+ * nfsd3_proc_setacl - SETACL: Set the Access and/or Default ACL of a file
+ * @rqstp: RPC transaction context
+ *
+ * Return:
+ *   %rpc_success:		RPC executed successfully
+ *
+ * RPC synopsis:
+ *   SETACL3res ACLPROC3_SETACL(SETACL3args) = 2;
  */
 static __be32 nfsd3_proc_setacl(struct svc_rqst *rqstp)
 {
-	struct nfsd3_setaclargs *argp = rqstp->rq_argp;
-	struct nfsd3_attrstat *resp = rqstp->rq_resp;
+	struct SETACL3args_wrapper *argp = rqstp->rq_argp;
+	struct SETACL3res_wrapper *resp = rqstp->rq_resp;
+	struct svc_fh *fhp = &argp->fh;
 	struct inode *inode;
-	svc_fh *fh;
 	int error;
 
-	fh = fh_copy(&resp->fh, &argp->fh);
-	resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
-	if (resp->status != acl3_ok)
+	resp->xdrgen.u.resok.attr.attributes_follow = false;
+
+	if (!nfs3acl_decode_fh(&argp->xdrgen.fh, fhp)) {
+		resp->xdrgen.status = acl3err_badhandle;
+		return rpc_success;
+	}
+
+	resp->xdrgen.status = fh_verify(rqstp, fhp, 0, NFSD_MAY_SATTR);
+	if (resp->xdrgen.status != acl3_ok)
 		goto out;
+	inode = d_inode(fhp->fh_dentry);
 
-	inode = d_inode(fh->fh_dentry);
+	if (argp->invalid) {
+		resp->xdrgen.status = acl3err_inval;
+		goto out;
+	}
 
-	error = fh_want_write(fh);
+	/* The VFS reports a default ACL on a non-directory as EACCES. */
+	if (argp->acl_default && !S_ISDIR(inode->i_mode)) {
+		resp->xdrgen.status = acl3err_inval;
+		goto out;
+	}
+
+	error = fh_want_write(fhp);
 	if (error)
 		goto out_errno;
 
 	inode_lock(inode);
 
 	error = 0;
-	if (argp->mask & NA_ACL) {
-		error = set_posix_acl(&nop_mnt_idmap, fh->fh_dentry,
+	if (argp->xdrgen.acl.mask & NA_ACL) {
+		error = set_posix_acl(&nop_mnt_idmap, fhp->fh_dentry,
 				      ACL_TYPE_ACCESS, argp->acl_access);
 		if (error)
 			goto out_drop_lock;
 	}
-	if (argp->mask & NA_DFACL) {
-		error = set_posix_acl(&nop_mnt_idmap, fh->fh_dentry,
+	if (argp->xdrgen.acl.mask & NA_DFACL) {
+		error = set_posix_acl(&nop_mnt_idmap, fhp->fh_dentry,
 				      ACL_TYPE_DEFAULT, argp->acl_default);
+		if (error)
+			goto out_drop_lock;
 	}
 
+	inode_unlock(inode);
+
+	fh_drop_write(fhp);
+
+out:
+	/*
+	 * resok and resfail both open with a post_op_attr, so filling
+	 * the resok arm serves either status.
+	 */
+	if (!fhp->fh_no_wcc && fhp->fh_dentry &&
+	    fh_getattr(fhp, &resp->stat) == acl3_ok)
+		nfs3acl_encode_post_op_attr(rqstp, &resp->xdrgen.u.resok.attr,
+					    &resp->stat, fhp);
+	/* argp->acl_{access,default} are released in nfs3svc_release_setacl. */
+	fh_put(fhp);
+	resp->xdrgen.status = nfsd3_map_status(resp->xdrgen.status);
+	return rpc_success;
+
 out_drop_lock:
 	inode_unlock(inode);
-	fh_drop_write(fh);
+	fh_drop_write(fhp);
 out_errno:
-	resp->status = nfsd3_map_errno(error);
-out:
-	/* argp->acl_{access,default} are released in nfs3svc_release_setacl. */
-	resp->status = nfsd3_map_status(resp->status);
-	return rpc_success;
-}
-
-/*
- * XDR decode functions
- */
-
-static bool
-nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	struct nfsd3_setaclargs *argp = rqstp->rq_argp;
-
-	if (!svcxdr_decode_nfs_fh3(xdr, &argp->fh))
-		return false;
-	if (xdr_stream_decode_u32(xdr, &argp->mask) < 0)
-		return false;
-	if (argp->mask & ~NFS_ACL_MASK)
-		return false;
-	if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NA_ACL) ?
-				   &argp->acl_access : NULL))
-		return false;
-	if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NA_DFACL) ?
-				   &argp->acl_default : NULL))
-		return false;
-
-	return true;
-}
-
-/*
- * XDR encode functions
- */
-
-/* SETACL */
-static bool
-nfs3svc_encode_setaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	struct nfsd3_attrstat *resp = rqstp->rq_resp;
-
-	return svcxdr_encode_nfsstat3(xdr, resp->status) &&
-		svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh);
+	resp->xdrgen.status = nfsd3_map_errno(error);
+	goto out;
 }
 
 /*
@@ -655,18 +639,12 @@ static void nfs3svc_release_getacl(struct svc_rqst *rqstp)
 
 static void nfs3svc_release_setacl(struct svc_rqst *rqstp)
 {
-	struct nfsd3_setaclargs *argp = rqstp->rq_argp;
-	struct nfsd3_attrstat *resp = rqstp->rq_resp;
+	struct SETACL3args_wrapper *argp = rqstp->rq_argp;
 
-	fh_put(&resp->fh);
 	posix_acl_release(argp->acl_access);
 	posix_acl_release(argp->acl_default);
 }
 
-#define ST 1		/* status*/
-#define AT 21		/* attributes */
-#define pAT (1+AT)	/* post attributes - conditional */
-
 static const struct svc_procedure nfsd_acl_procedures3[3] = {
 	[ACLPROC3_NULL] = {
 		.pc_func = nfsd3_proc_null,
@@ -693,14 +671,14 @@ static const struct svc_procedure nfsd_acl_procedures3[3] = {
 	},
 	[ACLPROC3_SETACL] = {
 		.pc_func = nfsd3_proc_setacl,
-		.pc_decode = nfs3svc_decode_setaclargs,
-		.pc_encode = nfs3svc_encode_setaclres,
+		.pc_decode = nfs_acl_svc_decode_SETACL3args,
+		.pc_encode = nfs_acl_svc_encode_SETACL3res,
 		.pc_release = nfs3svc_release_setacl,
-		.pc_argsize = sizeof(struct nfsd3_setaclargs),
-		.pc_argzero = sizeof(struct nfsd3_setaclargs),
-		.pc_ressize = sizeof(struct nfsd3_attrstat),
+		.pc_argsize = sizeof(struct SETACL3args_wrapper),
+		.pc_argzero = sizeof(struct SETACL3args_wrapper),
+		.pc_ressize = sizeof(struct SETACL3res_wrapper),
 		.pc_cachetype = RC_NOCACHE,
-		.pc_xdrressize = ST+pAT,
+		.pc_xdrressize = NFS_ACL3_SETACL3res_sz,
 		.pc_name = "SETACL",
 	},
 };
@@ -710,9 +688,9 @@ static const struct svc_procedure nfsd_acl_procedures3[3] = {
  */
 union nfsd_acl3_xdrstore {
 	struct GETACL3args_wrapper	getaclargs;
-	struct nfsd3_setaclargs		setaclargs;
+	struct SETACL3args_wrapper	setaclargs;
 	struct GETACL3res_wrapper	getaclres;
-	struct nfsd3_attrstat		attrstat;
+	struct SETACL3res_wrapper	setaclres;
 };
 
 const struct svc_version nfsd_acl_version3 = {
Signature · 1 line
2.56.0
author maintainer
#9 lore raw

PATCH 9/13 NFSD: Map every NFS_ACLv3 reply status into aclstat3

In reply to Chuck Lever

nfsd3_map_status() translates only the two fh_verify() statuses that have no NFSv3 equivalent, so every other status reaches the encoder unchanged. fh_verify() and fh_getattr() pass errno values through nfserrno(), whose table produces NFSv3 status values that aclstat3 does not define. draft-ietf-nfsv4-nfs-acl Section 6.2 lists the status values an NFS_ACLv3 server returns, and those are not among them.

Pass through the statuses that are members of aclstat3 and map the rest to ACL3ERR_SERVERFAULT, the status nfsd3_map_errno() already uses for an unlisted errno. The existing NOFILEHANDLE and WRONGSEC translations are unchanged.

---
 fs/nfsd/nfs3acl.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
fs/nfsd/nfs3acl.c +19 -5
index 19f5a6127673..66bb650e99f4 100644
@@ -124,14 +124,28 @@ static __be32 nfsd3_map_errno(int errno)
 static __be32 nfsd3_map_status(__be32 status)
 {
 	switch (status) {
+	case acl3_ok:
+	case acl3err_perm:
+	case acl3err_noent:
+	case acl3err_io:
+	case acl3err_acces:
+	case acl3err_inval:
+	case acl3err_nospc:
+	case acl3err_rofs:
+	case acl3err_dquot:
+	case acl3err_stale:
+	case acl3err_badhandle:
+	case acl3err_notsupp:
+	case acl3err_serverfault:
+	case acl3err_jukebox:
+		return status;
 	case cpu_to_be32(NFS4ERR_NOFILEHANDLE):
-		status = acl3err_badhandle;
-		break;
+		return acl3err_badhandle;
 	case cpu_to_be32(NFS4ERR_WRONGSEC):
-		status = acl3err_acces;
-		break;
+		return acl3err_acces;
+	default:
+		return acl3err_serverfault;
 	}
-	return status;
 }
 
 static bool
Signature · 1 line
2.56.0
author maintainer
#10 lore raw

PATCH 10/13 NFSD: Remove the hand-coded XDR helpers for the NFS_ACLv3 procedures

In reply to Chuck Lever

The NFS_ACLv3 GETACL and SETACL procedures were the last callers of svcxdr_decode_nfs_fh3(), svcxdr_encode_nfsstat3(), and svcxdr_encode_post_op_attr(). With their arguments and replies now handled by xdrgen, the three helpers have no caller, and svcxdr_encode_fattr3(), nfs3_ftypes[], and encode_nfstime3() have no caller other than svcxdr_encode_post_op_attr().

Remove the hand-coded helpers and their declarations in xdr3.h.

---
 fs/nfsd/nfs3xdr.c | 166 ----------------------------------------------
 fs/nfsd/xdr3.h    |   5 --
 2 files changed, 171 deletions(-)
fs/nfsd/nfs3xdr.c +0 -166
index 850647ac98bb..8e231e0eb0f8 100644
@@ -20,172 +20,6 @@
 
 #include "nfs3xdr_gen.h"
 
-/*
- * Mapping of S_IF* types to NFS file types
- */
-static const u32 nfs3_ftypes[] = {
-	NF3NON,  NF3FIFO, NF3CHR, NF3BAD,
-	NF3DIR,  NF3BAD,  NF3BLK, NF3BAD,
-	NF3REG,  NF3BAD,  NF3LNK, NF3BAD,
-	NF3SOCK, NF3BAD,  NF3LNK, NF3BAD,
-};
-
-
-/*
- * Basic NFSv3 data types (RFC 1813 Sections 2.5 and 2.6)
- */
-
-static __be32 *
-encode_nfstime3(__be32 *p, const struct timespec64 *time)
-{
-	*p++ = cpu_to_be32((u32)time->tv_sec);
-	*p++ = cpu_to_be32(time->tv_nsec);
-
-	return p;
-}
-
-/**
- * svcxdr_decode_nfs_fh3 - Decode an NFSv3 file handle
- * @xdr: XDR stream positioned at an undecoded NFSv3 FH
- * @fhp: OUT: filled-in server file handle
- *
- * Return values:
- *  %false: The encoded file handle was not valid
- *  %true: @fhp has been initialized
- */
-bool
-svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp)
-{
-	__be32 *p;
-	u32 size;
-
-	if (xdr_stream_decode_u32(xdr, &size) < 0)
-		return false;
-	if (size == 0 || size > NFS3_FHSIZE)
-		return false;
-	p = xdr_inline_decode(xdr, size);
-	if (!p)
-		return false;
-	fh_init(fhp, NFS3_FHSIZE);
-	fhp->fh_handle.fh_size = size;
-	memcpy(&fhp->fh_handle.fh_raw, p, size);
-
-	return true;
-}
-
-/**
- * svcxdr_encode_nfsstat3 - Encode an NFSv3 status code
- * @xdr: XDR stream
- * @status: status value to encode
- *
- * Return values:
- *   %false: Send buffer space was exhausted
- *   %true: Success
- */
-bool
-svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status)
-{
-	__be32 *p;
-
-	p = xdr_reserve_space(xdr, sizeof(status));
-	if (!p)
-		return false;
-	*p = status;
-
-	return true;
-}
-
-static bool
-svcxdr_encode_fattr3(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-		     const struct svc_fh *fhp, const struct kstat *stat)
-{
-	struct user_namespace *userns = nfsd_user_namespace(rqstp);
-	__be32 *p;
-	u64 fsid;
-
-	p = xdr_reserve_space(xdr, XDR_UNIT * 21);
-	if (!p)
-		return false;
-
-	*p++ = cpu_to_be32(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
-	*p++ = cpu_to_be32((u32)(stat->mode & S_IALLUGO));
-	*p++ = cpu_to_be32((u32)stat->nlink);
-	*p++ = cpu_to_be32((u32)from_kuid_munged(userns, stat->uid));
-	*p++ = cpu_to_be32((u32)from_kgid_munged(userns, stat->gid));
-	if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN)
-		p = xdr_encode_hyper(p, (u64)NFS3_MAXPATHLEN);
-	else
-		p = xdr_encode_hyper(p, (u64)stat->size);
-
-	/* used */
-	p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9);
-
-	/* rdev */
-	*p++ = cpu_to_be32((u32)MAJOR(stat->rdev));
-	*p++ = cpu_to_be32((u32)MINOR(stat->rdev));
-
-	switch(fsid_source(fhp)) {
-	case FSIDSOURCE_FSID:
-		fsid = (u64)fhp->fh_export->ex_fsid;
-		break;
-	case FSIDSOURCE_UUID:
-		fsid = ((u64 *)fhp->fh_export->ex_uuid)[0];
-		fsid ^= ((u64 *)fhp->fh_export->ex_uuid)[1];
-		break;
-	default:
-		fsid = (u64)huge_encode_dev(fhp->fh_dentry->d_sb->s_dev);
-	}
-	p = xdr_encode_hyper(p, fsid);
-
-	/* fileid */
-	p = xdr_encode_hyper(p, stat->ino);
-
-	p = encode_nfstime3(p, &stat->atime);
-	p = encode_nfstime3(p, &stat->mtime);
-	encode_nfstime3(p, &stat->ctime);
-
-	return true;
-}
-
-/**
- * svcxdr_encode_post_op_attr - Encode NFSv3 post-op attributes
- * @rqstp: Context of a completed RPC transaction
- * @xdr: XDR stream
- * @fhp: File handle to encode
- *
- * Return values:
- *   %false: Send buffer space was exhausted
- *   %true: Success
- */
-bool
-svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-			   const struct svc_fh *fhp)
-{
-	struct dentry *dentry = fhp->fh_dentry;
-	struct kstat stat;
-
-	/*
-	 * The inode may be NULL if the call failed because of a
-	 * stale file handle. In this case, no attributes are
-	 * returned.
-	 */
-	if (fhp->fh_no_wcc || !dentry || !d_really_is_positive(dentry))
-		goto no_post_op_attrs;
-	if (fh_getattr(fhp, &stat) != nfs_ok)
-		goto no_post_op_attrs;
-
-	if (xdr_stream_encode_item_present(xdr) < 0)
-		return false;
-	lease_get_mtime(d_inode(dentry), &stat.mtime);
-	if (!svcxdr_encode_fattr3(rqstp, xdr, fhp, &stat))
-		return false;
-
-	return true;
-
-no_post_op_attrs:
-	return xdr_stream_encode_item_absent(xdr) > 0;
-}
-
 /*
  * XDR encode functions
  */
fs/nfsd/xdr3.h +0 -5
index a6f0e0b7bfe4..90dadcacdf2b 100644
@@ -151,10 +151,5 @@ void nfsd3_fill_post_op_attr(struct svc_rqst *rqstp, struct post_op_attr *attr,
 			     struct svc_fh *fhp);
 void nfsd3_fill_post_op_fh3(struct post_op_fh3 *post_op_fh,
 			    const struct svc_fh *fhp, u8 *data);
-/* Helper functions for NFSv3 ACL code */
-bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
-bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
-bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
-				const struct svc_fh *fhp);
 
 #endif /* _LINUX_NFSD_XDR3_H */
Signature · 1 line
2.56.0
author maintainer
#11 lore raw

PATCH 11/13 NFS: Move NFSACL_MAXPAGES into fs/nfs/nfs3_fs.h

In reply to Chuck Lever

Only the NFSv3 client's ACL code reads NFSACL_MAXPAGES, yet the macro lives in <linux/nfsacl.h>, where it is the last reference to NFS_ACL_MAX_ENTRIES. <linux/nfsacl.h> no longer includes <uapi/linux/nfsacl.h>, so a file that includes only the kernel header cannot expand NFSACL_MAXPAGES. Move the macro next to its users and include nfs3_fs.h from nfs3xdr.c.

---
 fs/nfs/nfs3_fs.h       | 3 +++
 fs/nfs/nfs3xdr.c       | 1 +
 include/linux/nfsacl.h | 3 ---
 3 files changed, 4 insertions(+), 3 deletions(-)
fs/nfs/nfs3_fs.h +3 -0
index ffcabadb3546..09663adae033 100644
@@ -11,6 +11,9 @@
  * nfs3acl.c
  */
 #ifdef CONFIG_NFS_V3_ACL
+#define NFSACL_MAXPAGES		((2*(8+12*NFS_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \
+				 >> PAGE_SHIFT)
+
 extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu);
 extern int nfs3_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 			struct posix_acl *acl, int type);
fs/nfs/nfs3xdr.c +1 -0
index 3251c1434e71..19ab2fe84b8c 100644
@@ -25,6 +25,7 @@
 #include <linux/nfs_common.h>
 
 #include "internal.h"
+#include "nfs3_fs.h"
 #include "nfstrace.h"
 
 #define NFSDBG_FACILITY		NFSDBG_XDR
include/linux/nfsacl.h +0 -3
index 403f5f5144e3..5160f30151e8 100644
@@ -10,9 +10,6 @@
 #include <linux/posix_acl.h>
 #include <linux/sunrpc/xdr.h>
 
-#define NFSACL_MAXPAGES		((2*(8+12*NFS_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \
-				 >> PAGE_SHIFT)
-
 #define NFS_ACL_MAX_ENTRIES_INLINE	(5)
 #define NFS_ACL_INLINE_BUFSIZE	((2*(2+3*NFS_ACL_MAX_ENTRIES_INLINE)) << 2)
 
Signature · 1 line
2.56.0
maintainer Acked-by on v1 11/13
#12 lore raw

Re: [PATCH v1 11/13] NFS: Move NFSACL_MAXPAGES into fs/nfs/nfs3_fs.h

Hi Chuck,

Quoted 6 lines · Chuck Lever

Only the NFSv3 client's ACL code reads NFSACL_MAXPAGES, yet the macro lives in <linux/nfsacl.h>, where it is the last reference to NFS_ACL_MAX_ENTRIES. <linux/nfsacl.h> no longer includes <uapi/linux/nfsacl.h>, so a file that includes only the kernel header cannot expand NFSACL_MAXPAGES. Move the macro next to its users and include nfs3_fs.h from nfs3xdr.c.

I assume this should go through the NFSD tree with the rest of the patch series? If so:

Quoted 50 lines
---
 fs/nfs/nfs3_fs.h       | 3 +++
 fs/nfs/nfs3xdr.c       | 1 +
 include/linux/nfsacl.h | 3 ---
 3 files changed, 4 insertions(+), 3 deletions(-)
fs/nfs/nfs3_fs.h +3 -0
index ffcabadb3546..09663adae033 100644
@@ -11,6 +11,9 @@
  * nfs3acl.c
  */
 #ifdef CONFIG_NFS_V3_ACL
+#define NFSACL_MAXPAGES		((2*(8+12*NFS_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \
+				 >> PAGE_SHIFT)
+
 extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu);
 extern int nfs3_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 			struct posix_acl *acl, int type);
fs/nfs/nfs3xdr.c +1 -0
index 3251c1434e71..19ab2fe84b8c 100644
@@ -25,6 +25,7 @@
 #include <linux/nfs_common.h>
 
 #include "internal.h"
+#include "nfs3_fs.h"
 #include "nfstrace.h"
 
 #define NFSDBG_FACILITY		NFSDBG_XDR
include/linux/nfsacl.h +0 -3
index 403f5f5144e3..5160f30151e8 100644
@@ -10,9 +10,6 @@
 #include <linux/posix_acl.h>
 #include <linux/sunrpc/xdr.h>
 
-#define NFSACL_MAXPAGES		((2*(8+12*NFS_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \
-				 >> PAGE_SHIFT)
-
 #define NFS_ACL_MAX_ENTRIES_INLINE	(5)
 #define NFS_ACL_INLINE_BUFSIZE	((2*(2+3*NFS_ACL_MAX_ENTRIES_INLINE)) << 2)
 
Signature · 1 line
2.56.0
author maintainer
#13 lore raw

PATCH 12/13 NFSD: Share the attribute conversion helpers with the NFS_ACL procs

In reply to Chuck Lever

nfs2acl.c and nfs3acl.c each carry a private copy of the kstat to fattr conversion that nfsproc.c and nfs3proc.c already implement, down to the fsid selection and the symlink size clamp, along with a private definition of the path length limit the clamp uses. The copies exist because the NFS_ACL protocol descriptions define fattr, fattr3, and post_op_attr themselves, so the NFS_ACL proc files cannot include the native NFSv2 and NFSv3 generated headers, and xdr.h and xdr3.h pull those in. A fix to a native helper has to be repeated by hand in its NFS_ACL copy.

Add fattr.h, which declares nfsd_stat_to_fattr() and nfsd3_fill_post_op_attr() against incomplete struct types. The NFS_ACL copies of the attribute types match the native ones member for member, so each translation unit completes the types from its own protocol header and the helpers link across them. Export nfsd_stat_to_fattr() from nfsproc.c, move the nfsd3_fill_post_op_attr() prototype out of xdr3.h, and drop the NFS_ACL copies. With nfsd3_fill_post_op_attr() fetching the attributes itself, the NFS_ACLv3 result wrappers no longer carry a kstat.

---
 fs/nfsd/fattr.h   | 20 ++++++++++
 fs/nfsd/nfs2acl.c | 99 ++++-------------------------------------------
 fs/nfsd/nfs3acl.c | 87 ++---------------------------------------
 fs/nfsd/nfsproc.c |  3 +-
 fs/nfsd/xdr3.h    |  3 +-
 5 files changed, 34 insertions(+), 178 deletions(-)
 create mode 100644 fs/nfsd/fattr.h
fs/nfsd/fattr.h new file +20 -0
new file mode 100644
index 000000000000..7ea116c6a63c
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Attribute conversion helpers shared by the NFS and NFS_ACL procs.
+ */
+
+#ifndef _NFSD_FATTR_H
+#define _NFSD_FATTR_H
+
+struct fattr;
+struct kstat;
+struct post_op_attr;
+struct svc_fh;
+struct svc_rqst;
+
+void nfsd_stat_to_fattr(struct svc_rqst *rqstp, struct fattr *fattr,
+			const struct kstat *stat, const struct svc_fh *fhp);
+void nfsd3_fill_post_op_attr(struct svc_rqst *rqstp, struct post_op_attr *attr,
+			     struct svc_fh *fhp);
+
+#endif /* _NFSD_FATTR_H */
fs/nfsd/nfs2acl.c +8 -91

146 lines not on this page · raw message

fs/nfsd/nfs3acl.c +3 -84

132 lines not on this page · raw message

fs/nfsd/nfsproc.c +2 -1
index 39e5caa8e286..2f8da62ad6b0 100644
@@ -15,6 +15,7 @@
 #include "cache.h"
 #include "xdr.h"
 #include "vfs.h"
+#include "fattr.h"
 #include "nfserr.h"
 #include "trace.h"
 
@@ -189,7 +190,7 @@ nfsd_mode_to_ftype(umode_t mode)
 	return NFNON;
 }
 
-static void
+void
 nfsd_stat_to_fattr(struct svc_rqst *rqstp, struct fattr *fattr,
 		   const struct kstat *stat, const struct svc_fh *fhp)
 {
fs/nfsd/xdr3.h +1 -2
index 90dadcacdf2b..ae8afec767ef 100644
@@ -12,6 +12,7 @@
 #include <linux/sunrpc/xdrgen/nfs3.h>
 
 #include "vfs.h"
+#include "fattr.h"
 
 #define NF3NON		(0)
 #define NF3BAD		(8)
@@ -147,8 +148,6 @@ void nfs3svc_release_readdirplusres(struct svc_rqst *rqstp);
 
 void nfs3svc_encode_cookie3(struct xdr_stream *xdr, unsigned int pos,
 			    u64 cookie);
-void nfsd3_fill_post_op_attr(struct svc_rqst *rqstp, struct post_op_attr *attr,
-			     struct svc_fh *fhp);
 void nfsd3_fill_post_op_fh3(struct post_op_fh3 *post_op_fh,
 			    const struct svc_fh *fhp, u8 *data);
 
Signature · 1 line
2.56.0
author maintainer
#14 lore raw

PATCH 13/13 nfs_common: Remove the unused NFS ACL stream codecs

In reply to Chuck Lever

nfs_stream_encode_acl() and nfs_stream_decode_acl() served the hand-rolled NFSD codecs for the NFS_ACLv2 and NFS_ACLv3 GETACL and SETACL procedures. Those procedures now encode and decode ACL entries through generated codecs, and the NFS client has always used the xdr_buf variants, so neither function has a caller.

Remove both functions, their exports, and their declarations.

---
 fs/nfs_common/nfsacl.c | 125 -----------------------------------------
 include/linux/nfsacl.h |   6 --
 2 files changed, 131 deletions(-)
fs/nfs_common/nfsacl.c +0 -125
index a66294fcfb6e..cb43fa203a2c 100644
@@ -141,79 +141,6 @@ int nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
 }
 EXPORT_SYMBOL_GPL(nfsacl_encode);
 
-/**
- * nfs_stream_encode_acl - Encode an NFSv3 ACL
- *
- * @xdr: an xdr_stream positioned to receive an encoded ACL
- * @inode: inode of file whose ACL this is
- * @acl: posix_acl to encode
- * @encode_entries: whether to encode ACEs as well
- * @typeflag: ACL type: NFS_ACL_DEFAULT or zero
- *
- * Return values:
- *   %false: The ACL could not be encoded
- *   %true: @xdr is advanced to the next available position
- */
-bool nfs_stream_encode_acl(struct xdr_stream *xdr, struct inode *inode,
-			   struct posix_acl *acl, int encode_entries,
-			   int typeflag)
-{
-	const size_t elem_size = XDR_UNIT * 3;
-	u32 entries = (acl && acl->a_count >= 3) ?
-		      max_t(int, acl->a_count, 4) : 0;
-	struct nfsacl_encode_desc nfsacl_desc = {
-		.desc = {
-			.elem_size = elem_size,
-			.array_len = encode_entries ? entries : 0,
-			.xcode = xdr_nfsace_encode,
-		},
-		.acl = acl,
-		.typeflag = typeflag,
-		.uid = inode->i_uid,
-		.gid = inode->i_gid,
-	};
-	struct nfsacl_simple_acl aclbuf;
-	unsigned int base;
-	int err;
-
-	if (entries > NFS_ACL_MAX_ENTRIES)
-		return false;
-	if (xdr_stream_encode_u32(xdr, entries) < 0)
-		return false;
-
-	if (encode_entries && acl && acl->a_count == 3) {
-		struct posix_acl *acl2 =
-			container_of(&aclbuf.acl, struct posix_acl, hdr);
-
-		/* Avoid the use of posix_acl_alloc().  nfsacl_encode() is
-		 * invoked in contexts where a memory allocation failure is
-		 * fatal.  Fortunately this fake ACL is small enough to
-		 * construct on the stack. */
-		posix_acl_init(acl2, 4);
-
-		/* Insert entries in canonical order: other orders seem
-		 to confuse Solaris VxFS. */
-		acl2->a_entries[0] = acl->a_entries[0];  /* ACL_USER_OBJ */
-		acl2->a_entries[1] = acl->a_entries[1];  /* ACL_GROUP_OBJ */
-		acl2->a_entries[2] = acl->a_entries[1];  /* ACL_MASK */
-		acl2->a_entries[2].e_tag = ACL_MASK;
-		acl2->a_entries[3] = acl->a_entries[2];  /* ACL_OTHER */
-		nfsacl_desc.acl = acl2;
-	}
-
-	base = xdr_stream_pos(xdr);
-	if (!xdr_reserve_space(xdr, XDR_UNIT +
-			       elem_size * nfsacl_desc.desc.array_len))
-		return false;
-	err = xdr_encode_array2(xdr->buf, base, &nfsacl_desc.desc);
-	if (err)
-		return false;
-
-	return true;
-}
-EXPORT_SYMBOL_GPL(nfs_stream_encode_acl);
-
-
 struct nfsacl_decode_desc {
 	struct xdr_array2_desc desc;
 	unsigned int count;
@@ -380,55 +307,3 @@ int nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
 		   nfsacl_desc.desc.array_len;
 }
 EXPORT_SYMBOL_GPL(nfsacl_decode);
-
-/**
- * nfs_stream_decode_acl - Decode an NFSv3 ACL
- *
- * @xdr: an xdr_stream positioned at an encoded ACL
- * @aclcnt: OUT: count of ACEs in decoded posix_acl
- * @pacl: OUT: a dynamically-allocated buffer containing the decoded posix_acl
- *
- * Return values:
- *   %false: The encoded ACL is not valid
- *   %true: @pacl contains a decoded ACL, and @xdr is advanced
- *
- * On a successful return, caller must release *pacl using posix_acl_release().
- */
-bool nfs_stream_decode_acl(struct xdr_stream *xdr, unsigned int *aclcnt,
-			   struct posix_acl **pacl)
-{
-	const size_t elem_size = XDR_UNIT * 3;
-	struct nfsacl_decode_desc nfsacl_desc = {
-		.desc = {
-			.elem_size = elem_size,
-			.xcode = pacl ? xdr_nfsace_decode : NULL,
-		},
-	};
-	unsigned int base;
-	u32 entries;
-
-	if (xdr_stream_decode_u32(xdr, &entries) < 0)
-		return false;
-	if (entries > NFS_ACL_MAX_ENTRIES)
-		return false;
-
-	base = xdr_stream_pos(xdr);
-	if (!xdr_inline_decode(xdr, XDR_UNIT + elem_size * entries))
-		return false;
-	nfsacl_desc.desc.array_maxlen = entries;
-	if (xdr_decode_array2(xdr->buf, base, &nfsacl_desc.desc))
-		return false;
-
-	if (pacl) {
-		if (entries != nfsacl_desc.desc.array_len ||
-		    posix_acl_from_nfsacl(nfsacl_desc.acl) != 0) {
-			posix_acl_release(nfsacl_desc.acl);
-			return false;
-		}
-		*pacl = nfsacl_desc.acl;
-	}
-	if (aclcnt)
-		*aclcnt = entries;
-	return true;
-}
-EXPORT_SYMBOL_GPL(nfs_stream_decode_acl);
include/linux/nfsacl.h +0 -6
index 5160f30151e8..4ad81b2b2623 100644
@@ -30,12 +30,6 @@ nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
 extern int
 nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
 	      struct posix_acl **pacl);
-extern bool
-nfs_stream_decode_acl(struct xdr_stream *xdr, unsigned int *aclcnt,
-		      struct posix_acl **pacl);
-extern bool
-nfs_stream_encode_acl(struct xdr_stream *xdr, struct inode *inode,
-		      struct posix_acl *acl, int encode_entries, int typeflag);
 extern int
 posix_acl_from_nfsacl(struct posix_acl *acl);
 
Signature · 1 line
2.56.0
maintainer Acked-by on the v1 series
#15 lore raw
In reply to Chuck Lever
Quoted 34 lines · Chuck Lever

Replace NFSD's NFS_ACLv3 XDR encoders and decoders with code that is mechanically generated from the protocol's RPC language description. No RFC defines NFS_ACL. The description in nfs_acl3.x is copied from draft-ietf-nfsv4-nfs-acl.

Chuck Lever (13):
Documentation: Add the RPC language description of NFS_ACLv3
NFSD: Add infrastructure for generating NFS_ACLv3 XDR encoders and
decoders
NFSD: Remove '#include "xdr3.h"' from nfs3acl.c
NFSD: New NFS_ACLv3 status codes
NFSD: Use xdrgen XDR functions for the NFS-ACL v3 NULL procedure
NFSD: Implement NFS-ACL v3 ACL encoding and decoding with xdrgen
NFSD: Use xdrgen XDR functions for the NFS-ACL v3 GETACL procedure
NFSD: Use xdrgen XDR functions for the NFS-ACL v3 SETACL procedure
NFSD: Map every NFS_ACLv3 reply status into aclstat3
NFSD: Remove the hand-coded XDR helpers for the NFS_ACLv3 procedures
NFS: Move NFSACL_MAXPAGES into fs/nfs/nfs3_fs.h
NFSD: Share the attribute conversion helpers with the NFS_ACL procs
nfs_common: Remove the unused NFS ACL stream codecs

 Documentation/sunrpc/xdr/nfs_acl3.x    | 273 ++++++++
 fs/nfs/nfs3_fs.h                       |   3 +
 fs/nfs/nfs3xdr.c                       |   1 +
 fs/nfs_common/nfsacl.c                 | 125 ----
 fs/nfsd/Makefile                       |  13 +-
 fs/nfsd/fattr.h                        |  20 +
 fs/nfsd/nfs2acl.c                      |  99 +--
 fs/nfsd/nfs3acl.c                      | 623 +++++++++++++-----
 fs/nfsd/nfs3xdr.c                      | 166 -----
 fs/nfsd/nfs_acl3xdr_gen.c              | 839 +++++++++++++++++++++++++
 fs/nfsd/nfs_acl3xdr_gen.h              |  36 ++
 fs/nfsd/nfsproc.c                      |   3 +-
 fs/nfsd/xdr3.h                         |   8 +-
Quoted 8 lines
 include/linux/nfsacl.h                 |   9 -
 include/linux/sunrpc/xdrgen/nfs_acl3.h | 284 +++++++++
 15 files changed, 1948 insertions(+), 554 deletions(-)
 create mode 100644 Documentation/sunrpc/xdr/nfs_acl3.x
 create mode 100644 fs/nfsd/fattr.h
 create mode 100644 fs/nfsd/nfs_acl3xdr_gen.c
 create mode 100644 fs/nfsd/nfs_acl3xdr_gen.h
 create mode 100644 include/linux/sunrpc/xdrgen/nfs_acl3.h

This all looks fine to me.