Linux NFS development
 help / color / mirror / Atom feed
From: "Anna Schumaker" <anna@kernel.org>
To: "Chuck Lever" <cel@kernel.org>, NeilBrown <neil@brown.name>,
	"Jeff Layton" <jlayton@kernel.org>,
	"Olga Kornievskaia" <okorniev@redhat.com>,
	"Dai Ngo" <dai.ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
	"Trond Myklebust" <trond.myklebust@hammerspace.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH v1 1/2] nfs_common: Do not encode an ACL with fewer than three entries
Date: Fri, 02 Oct 2026 13:24:23 -0400	[thread overview]
Message-ID: <2c429fd9-33d5-4045-b478-e1e9e5d68081@app.fastmail.com> (raw)
In-Reply-To: <20260924212246.114355-2-cel@kernel.org>



On Thu, Sep 24, 2026, at 5:22 PM, Chuck Lever wrote:
> nfsacl_encode() reports at least four wire entries for any ACL
> that has entries, because a three-entry ACL is sent as four with a
> synthesized ACL_MASK. The entry encoder then walks a_entries[] up
> to that count.
>
> A one- or two-entry ACL cannot arrive from setfacl, because
> set_posix_acl() validates it first. It can arrive from an NFS
> server. The NFS client caches a GETACL result without validating
> it, and posix_acl_create() hands the cached default ACL to
> nfs3_proc_setacls() when the client creates a directory. The walk
> then reads past the end of the posix_acl allocation and copies the
> bytes into the SETACL arguments.
>
> Report zero wire entries for an ACL with fewer than three, the
> same as for an ACL with none. Count them the same way in
> nfsacl_size(), which otherwise sizes such an ACL at four entries
> and leaves the reserved bytes unwritten in the SETACL arguments.
>
> Fixes: a257cdd0e217 ("[PATCH] NFSD: Add server support for NFSv3 ACLs.")
> Signed-off-by: Chuck Lever <cel@kernel.org>

Acked-by: Anna Schumaker <anna.schumaker@hammerspace.com>


> ---
>  fs/nfs_common/nfsacl.c | 3 ++-
>  include/linux/nfsacl.h | 5 +++--
>  2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfs_common/nfsacl.c b/fs/nfs_common/nfsacl.c
> index e2eaac14fd8e..38bb2c294d7c 100644
> --- a/fs/nfs_common/nfsacl.c
> +++ b/fs/nfs_common/nfsacl.c
> @@ -93,7 +93,8 @@ xdr_nfsace_encode(struct xdr_array2_desc *desc, void *elem)
>  int nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
>  		  struct posix_acl *acl, int encode_entries, int typeflag)
>  {
> -	int entries = (acl && acl->a_count) ? max_t(int, acl->a_count, 4) : 0;
> +	int entries = (acl && acl->a_count >= 3) ?
> +		      max_t(int, acl->a_count, 4) : 0;
>  	struct nfsacl_encode_desc nfsacl_desc = {
>  		.desc = {
>  			.elem_size = 12,
> diff --git a/include/linux/nfsacl.h b/include/linux/nfsacl.h
> index 8e76a79cdc6a..e4155e69c8dd 100644
> --- a/include/linux/nfsacl.h
> +++ b/include/linux/nfsacl.h
> @@ -26,8 +26,9 @@ static inline unsigned int
>  nfsacl_size(struct posix_acl *acl_access, struct posix_acl *acl_default)
>  {
>  	unsigned int w = 16;
> -	w += max(acl_access ? (int)acl_access->a_count : 3, 4) * 12;
> -	if (acl_default)
> +	if (acl_access && acl_access->a_count >= 3)
> +		w += max((int)acl_access->a_count, 4) * 12;
> +	if (acl_default && acl_default->a_count >= 3)
>  		w += max((int)acl_default->a_count, 4) * 12;
>  	return w;
>  }
> -- 
> 2.55.0

  reply	other threads:[~2026-10-02 17:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 21:22 [PATCH v1 0/2] nfs_common: Encode an ACL with fewer than three entries as empty Chuck Lever
2026-09-24 21:22 ` [PATCH v1 1/2] nfs_common: Do not encode an ACL with fewer than three entries Chuck Lever
2026-10-02 17:24   ` Anna Schumaker [this message]
2026-09-24 21:22 ` [PATCH v1 2/2] nfs_common: Do not stream-encode " Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c429fd9-33d5-4045-b478-e1e9e5d68081@app.fastmail.com \
    --to=anna@kernel.org \
    --cc=cel@kernel.org \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    --cc=trond.myklebust@hammerspace.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox