Skip to contentSkip to conversation

nfs_common: release decoded ACL on nfsacl_decode() error

PATCH In review Chengyu Liu 2 participants 3 messages Nov 3 – Nov 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs_common: release decoded ACL on nfsacl_decode() error

nfsacl_decode() is used by the NFSv3 client to decode GETACL replies. xdr_nfsace_decode() allocates desc->acl with posix_acl_alloc() before validating the entry contents, and the out: path of xdr_xcode_array2() only frees its temporary element buffer. If decoding fails partway (e.g. an entry with an invalid id), nfsacl_decode() returns the error without releasing nfsacl_desc.acl, leaking an up-to- NFS_ACL_MAX_ENTRIES acl (about 8KB, a kmalloc-16K slot) per failed reply.

A malicious or compromised NFSv3 server can repeat this for every client GETACL (getfacl, getxattr system.posix_acl_access - also issued periodically by backup/scanner agents), slowly leaking client kernel memory.

Release the acl on the error path; posix_acl_release() is NULL-safe.

Found by static analysis.

---
 fs/nfs_common/nfsacl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfs_common/nfsacl.c +3 -1
index e2eaac14fd..e7ad47e2ca 100644
@@ -353,8 +353,10 @@ int nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
 		return -EINVAL;
 	nfsacl_desc.desc.array_maxlen = entries;
 	err = xdr_decode_array2(buf, base + 4, &nfsacl_desc.desc);
-	if (err)
+	if (err) {
+		posix_acl_release(nfsacl_desc.acl);
 		return err;
+	}
 	if (pacl) {
 		if (entries != nfsacl_desc.desc.array_len ||
 		    posix_acl_from_nfsacl(nfsacl_desc.acl) != 0) {
Signature · 1 line
2.25.1
#1 lore raw

Hi,

I noticed that the Patchwork status of my patch has changed to "Handled Elsewhere". I'm not sure how to interpret this status. Has the patch been picked up by another maintainer, or is there anything I need to do on my end, such as resubmitting it to another mailing list?

Any clarification would be appreciated.

Thanks!

maintainer
#2 lore raw
Quoted 6 lines · Chengyu Liu

Hi,

I noticed that the Patchwork status of my patch has changed to "Handled Elsewhere". I'm not sure how to interpret this status. Has the patch been picked up by another maintainer, or is there anything I need to do on my end, such as resubmitting it to another mailing list?

I manage the patchwork instance for NFSD. The NFS client maintainers don't use it. "Handled elsewhere" in this case means I could have taken it through the NFSD tree, but since the NFS client is now the only consumer of that API, I'm going to let the client folks handle it.

Signature · 1 line
Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)