From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796099582; b=aB3TGl/KF9dgjcSqrm7TugpWf3OwMIKP50cvVRs1y+iJt65Scb/WbQd07/piYO/2YbH2 YENWwA6wt9oeNC6CbcI7k5bMXViwMCLOeaCaADYOMLFPPRnmu0ZM/DBgxwOFkw7YC8djl R2C93uWTa+5TuyglbjcRCOEIQ39rV02SoDlczGZsWNUX48eIYwySMIBfI5Wcsu0oJOMaD vqIkFuOdKwb/1j/tuixhw7f4UbmEUxrCyf+pCglwdMFWBWFKZjXOCMFYjemwEcNumXt5t KygP5RmWT0SGqnmszaw725v3oVIjAh1ZAg9fW3EvxhUmHnqf6zjUvsoQBaBQUY1AWOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796099582; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=5pNh/3RSTvWyH8/ARSr0/ZLwWMwMMEYevfieY7bMWzM=; b=49gkWV3G7Sx6oj3mYntSIXPOODS6qJ3i2f/TnDAtFg3qzc31TnocNGg2NfuagO4Kh6WT MJpqx8n1QqrijgR4Tz+IGGCTNECtQQxwOVO6bCFIClW80KRiUWiTfrtI8S/hQbxvyoJkn LaDKrqRcONTCEtCRt4yjsTGZqZhEoYmp42kItFIBZ8sz2KwCHiiaav3aotZNM94je/jkp S64pY2pHKuZ6c5HmWvNTyo6Att0Z47pIv9IMkJ8/LnSzBHy56zuLcnZh7lRUrO1EZTZJP j01SeSTjKrH57KWc3QWNPydqzf0R/A6uiblcILStH9CdkvK4J8HGrL47p2+kTmyIP2g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Ciwie5Ak; arc=none smtp.remote-ip=74.125.82.173 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B49606A31A for ; Tue, 1 Dec 2026 04:33:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 86B49606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Ciwie5Ak Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-385c497bf94so15405330eec.1 for ; Mon, 30 Nov 2026 20:33:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796099581; x=1796704381; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=5pNh/3RSTvWyH8/ARSr0/ZLwWMwMMEYevfieY7bMWzM=; b=Ciwie5AkuO0M+OHomR2zpe+egzj5RqNNrOJM7gJuqG+0Df/75TmoXui6IbiJ7eLDht 9a3FEPVtT2RVid2nHRoziLKpeBTDpIunUQ9KNWsz3ku62OqUmTaLj32bb5tPOaLc3P2l zgTOs8xzsZsyFyLOaa5AocoPSFR/oEo6s+Vv/m1eJeUsiqsujSAxFWmUTdj+xFKICEci B4Ob2nOnpAVkpgp8sHHagI/U6PQNhvUfUjCMl/DQgHcGjiHHrZTy2PiTZx173VHhThkP DWSTVykMC8R9bixzTIFy2t9BOypmRih+xRvHulm+8gX73XPafFoFZC/k/E+K0Uetw9i4 K8ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796099582; x=1796704382; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5pNh/3RSTvWyH8/ARSr0/ZLwWMwMMEYevfieY7bMWzM=; b=U1oBN7YwqLOsIqJxYHRnvXKML93OgN6Lz0MwbyQ6xUEjDp1WU/C/ntaypLudTccUkB JS71MPLsN2IPKk+94fgTwmD4UyuCy4Ju03Ut0kA5opOZGzQQ0BcyKNiQz1QaJmT+bH48 spZLeDvNWLNGXZQx9mEge03w1OjSHXbY274V6nRq4IZvwmcL0qE6+m1NIpKPR3nMK6ZE 3lBqzYLZ7ZJ38M2cwBoS8k9ZnYwFG/zD3xkg9d5Q9UOxLp1C59aDiv8p/Ha59ueQnZZr xqrKu7f6uwvQNbjjiiSgevUHRmLcegyLAisFIMI0vtAC4tNBtPg6EolyJMrNZdhpUZgJ tIoA== X-Forwarded-Encrypted: i=1; AL+hErERdcoDvvdskS+8kNGtZ4ry6xJc1xVIhg/3FgRXZF68R5gmNJdt6snN9iHeEp+4ZxWOPw4NnQ9O5rw=@vger.kernel.org X-Gm-Message-State: APuU4Z9gSVwc6zOcE5Bhm9rO0DE/3wmdq7SKNIQ0hbyG2ACXq/0oco+5 lk4Fu+6MWLxBvJ9biN+q+6XSwUwysaazDNBzMto9Fk1XqzQfCcisCNME X-Gm-Gg: AZFdTZfEJMTUH17mtYqdfATB4ubKFFIlFnajpxCn832T2YO6k8llKcMu+P8nV4v+3q2 E1nPzorPg5QSlIeByAIFlCrSDAy8DMgLHHpZPv21Xt9pOAfgkKWQMev+FtZ+TtCANd+ikLZwkxv PMdOXKwzQCB4YyDJ2wIAYpV6pD2Ah+vdmlvEUP+GbOin/PdbWjHdekczg0T0jNdR95MdtZ+bejY Gis7eWVd9Hp/St4ZUjL/Ew1hnb/67v4iMxyis9crHV5VgbNKlE42qg8wC4i7oJ/opDromQYMvGg 4LvDPAnKxwyY+67ukU+bVnbkIDNxOJqo1S/6OlGcoIXeeIjwteq4EcqbSsUZQwxSj9GyG6RHSFJ ArRnYr6XfNclvZglR941iDWGGXwY1TAmy19mYTi0npdAvkHawofF6K0lUyeWQWohPQ5XGRJg1G8 KHRUKxSh6IY5o2DZIEYLpmkToRZL5w9S4u++norf8U1a9YvG9ADkX6xeEsYndMiNkkyrle/X2tx UprL8SvYcoO3p41ZKe6Qn0nzYQSmhR4Yu2EkXE7dLi/Q0yRip0ne/KMae5V775kFe46eu7EfQmQ dFdBLiiyC6A5rknHd6Czq8YpP7gWTzltzmUwxiUshAmhEz7GJS+mqT6rMTEK9vyicKoqfP/3IeD 4cw== X-Received: by 2002:a05:7300:2728:b0:383:c2f0:e753 with SMTP id 5a478bee46e88-3856c0d0a68mr39843559eec.3.1796099581476; Mon, 30 Nov 2026 20:33:01 -0800 (PST) Received: from localhost.localdomain ([123.215.20.10]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38566cd46c5sm131138620eec.11.2026.11.30.20.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 20:33:01 -0800 (PST) From: Yeonsu Jung To: Chuck Lever , Jeff Layton , Trond Myklebust , Anna Schumaker Cc: NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org, bobtobabz@gmail.com Subject: [PATCH] NFS: reject invalid decoded NFSACLs Date: Tue, 1 Dec 2026 13:32:38 +0900 Message-ID: <20261201043238.562-1-victorr0618@gmail.com> X-Mailer: git-send-email 2.55.0.windows.2 X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit posix_acl_from_nfsacl() sorts decoded NFSACL entries and removes the extra mask entry used by Solaris, but it does not validate the resulting POSIX ACL. A malicious NFS server can therefore return an ACL that ends in ACL_GROUP and lacks the required ACL_MASK and ACL_OTHER entries. If that NFS mount is re-exported, NFSD can pass the invalid ACL to _posix_to_nfsv4_one(). Its group walk assumes that posix_acl_valid() has already succeeded, so it can read beyond the ACL and emit more than the 2 * a_count ACEs allocated by nfsd4_get_nfs4_acl(), causing a heap out-of-bounds write. Validate the ACL after sorting and applying the Solaris compatibility fix. Have the NFSD request decoders record validation failures as semantic errors so that invalid SETACL requests continue to receive the protocol's INVAL response instead of RPC GARBAGE_ARGS. Validated on the nfsd-testing base shown below with an x86-64 kernel built by GCC 13.3 with W=1, CONFIG_WERROR=y, Generic KASAN, and lockdep. A validation-only fixture on the unpatched kernel supplied a three-entry GROUP-tail ACL with extra backing entries. The NFSv4 ACL converter emitted eight ACEs into a six-ACE allocation, and KASAN reported a slab-out-of-bounds write. On the patched kernel, the malformed ACL returned -EINVAL, while a valid Solaris ACL normalized successfully. In two-VM re-export tests, both Solaris and extended named-group ACLs produced successful downstream NFSv4.1 GETACL responses; 64 malformed ACL replies were rejected in each run. Normal NFSv4.1 mount, read/write, and unmount tests passed. No KASAN, lockdep, Oops, or panic report occurred in the patched runs. The vulnerability research and validation were conducted by members of the Tobabz team as part of the Best of the Best 15th program. Fixes: b7fa0554cf1b ("[PATCH] NFS: Add support for NFSv3 ACLs") Cc: stable@vger.kernel.org Signed-off-by: Yeonsu Jung --- fs/nfs_common/nfsacl.c | 5 +++-- fs/nfsd/nfs2acl.c | 4 +++- fs/nfsd/nfs3acl.c | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/nfs_common/nfsacl.c b/fs/nfs_common/nfsacl.c index cb43fa203a..25f450a9ef 100644 --- a/fs/nfs_common/nfsacl.c +++ b/fs/nfs_common/nfsacl.c @@ -224,7 +224,8 @@ cmp_acl_entry(const void *x, const void *y) * Sorts the entries into POSIX 1003.1e draft 17 order and removes the * bogus ACL_MASK entry Solaris adds to a minimal ACL. * - * Return: 0. Always succeeds; a NULL @acl is a no-op. + * Return: 0 if @acl is valid, otherwise a negative error code. A NULL @acl + * is a no-op. */ int posix_acl_from_nfsacl(struct posix_acl *acl) @@ -260,7 +261,7 @@ posix_acl_from_nfsacl(struct posix_acl *acl) sizeof(struct posix_acl_entry)); acl->a_count = 3; } - return 0; + return posix_acl_valid(&init_user_ns, acl); } EXPORT_SYMBOL_GPL(posix_acl_from_nfsacl); diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index ed41fc6dbc..b9a5b5a94b 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -695,7 +695,9 @@ bool nfs_acl2_secattr_decode_end(struct xdrgen_aggregate_cursor *c, bool ok) */ if (!ok || argp->invalid) return true; - return posix_acl_from_nfsacl(acl) == 0; + if (posix_acl_from_nfsacl(acl)) + argp->invalid = true; + return true; } /* diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index 50e5aee8b4..066397db9c 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c @@ -570,7 +570,9 @@ bool nfs_acl3_secattr_decode_end(struct xdrgen_aggregate_cursor *c, bool ok) */ if (!ok || argp->invalid) return true; - return posix_acl_from_nfsacl(acl) == 0; + if (posix_acl_from_nfsacl(acl)) + argp->invalid = true; + return true; } /* base-commit: 36fd4049e3c2bb901118e11be63bf7a7922bea8c -- 2.50.1 (Apple Git-155)