From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FA00367F3D for ; Thu, 28 May 2026 22:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.208.50 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780006311; cv=pass; b=vF4jWmD0z5YZ/MqmXIsBziGfyTl97aCd9JPR0qFC79X7FfzFKaHBH/i3wrsQ/cJneZS5QqY6tqA5nanCp9UvZV6TNPBEKqBidDAStQ0DNDyqFn4DUT5M1NcTP/JeDzfYO5B23AM7QV/YcltZqr5DFwxIIMBmWRla3L/BRxzXBpM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780006311; c=relaxed/simple; bh=Waq/q4WAgK2b1by/Ix28SSG66qgLx5KHlzodzTitIEk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Jww+LcWWz0nh4vijElUbTbQZePK3/LJbQ607caTZDwVI++uSuiOL3NbH2VBg8CFmdVJnvVmUapblNoQlX0t1QwL0OwhfC0mcYUT4xYROciCltM/dPJNSb0b8bNxwXG1PoVCQGBi2bpN2sW/2KEgWh23m4uvobhcUhDZt8KVt5yM= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k54iZCOI; arc=pass smtp.client-ip=209.85.208.50 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.b="k54iZCOI" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-68707d88626so4679046a12.0 for ; Thu, 28 May 2026 15:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780006308; cv=none; d=google.com; s=arc-20240605; b=ExJLavvWg4YN98Ppe/lJmYyKX8zMPpEXifP3XhC1foK6Q+7rpKOZsez8TOK2z3UZ8N 8TlRxYAb+4P8Uh1Zoj/JfAkZ44OzGOeNgwQWuvw4aCycMHEAjb3KMQaVOoizd+Psg2IQ zHz64S0A/OsG/arzsR05jFaUAnAW76zCI2v8tSaFPhCVcFRkskxJXr8Js1Tn4xQVBwPp zeR3w7GKELSFomDYbGqFdQMFuAOBP5sjWOtI3iSrB487t7CXWYyKBMHvUz7XXB4PK9zi OHXCkGnNQk3sGfY7EIzS7VC9+4aNvlWjbLJYiPdaBlXWq13tVFOJpRm3CFj4Zjf9fbRN TTSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=y64b9TPU+pG6hfyReL5O787YeVg5CpxfvXEJQobDNBM=; fh=6E/cfxj2+KIofL6beMJ9BtrXV6R6a45Z01a7H+FmtgQ=; b=HyK33CmK5ZdWo4AOa771smfhfmJwN1dJJo+k9bml8mOhZpGNllzwiFCAwj8Q9A6aB7 Sp+5hWfeizjG6bn7jyTzooJrHAdE1cPhCS3jFDvUK3ZzPeFfFeZNuX9lzOVrvgYsl/av +TU4rITy1NedATp228YgYC0t5HuTNxy/J/xHcVY5emaKLF1bKHPfsuxTfNexYm9JCLZ9 PVzCRxmqQg1sx6kdn8krXug/VpMhi196HsYLPfhDT9exIhHWvcUpfa8QCfdQvUASJJeG zMVUaaYwOSR501C76AF5vGe1S9Iat8QsNjm9NRKajZ+N9Kd5So9CQ9Gg9ZC89v6npL66 aqng==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780006308; x=1780611108; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=y64b9TPU+pG6hfyReL5O787YeVg5CpxfvXEJQobDNBM=; b=k54iZCOI+dlbYH2OyHFSbxg/ItUudVT0R2uNXNnTIujRIxTs97nX6I04qt1HS4Gxvq 3xwp9VXTiXQyFxeaToTDa4/B/v+KsJR+hBBqKYK4LQBzMmO8fq0W0iED6SsLD7UsIO5x HgFGvYTrPupvglcaozXpsOIkzz70TudPWCkyXexDY5buPPVKp3lYhtDtsaedqoMhHM8t xdgi+u5N4G1pXLlQWk04uyhnF8P8lN2lKHyv488E2Y6lDd3VW2GGL2bH4IliMazOzmd6 Zl+Dc8m85dkpZT7NFxQZXeFHEj/n6z7tqKJ2YJMNxzmVUCr8Q9sW7znLAUN+bZBoyYaP U+Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780006308; x=1780611108; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=y64b9TPU+pG6hfyReL5O787YeVg5CpxfvXEJQobDNBM=; b=tI+rNshSSXy5OE2atxVJTXW/lF4fiw2JxDRhHaV9VGtWxRLp4iuDhtrZ+ZhSBmcblV cqKzAazs+xJARRk+bRBhK5CoddlJzXqHzSYgCgePn1cVsYrMDi+f17D6sUNVQCxBLVvT Pf5n/KwhCaf7B/1lUMHa+4Rt+wCypDhN9U/ZTWZf/MPudonS0UsoIcrEw4+XYZQ178LO N5tcqPv7Z4iNetkS23M+W/8cK7k3FF5uZGAXRLFMVQFpbZJ3o/EcpuDgNAGZW/JM4/zF eukJbSZJw3estK317FcETYwuFtXQt9aAwaxVP+uvp2GA/HBMAyezn2kd3aQE/1Z5gn+E i0Hw== X-Forwarded-Encrypted: i=1; AFNElJ9CNBO3OTIgZVVdQ1oKNTwpcnExhQEQw9gaCGD42Stid+M24XxwvvDFMn6BITmQ4vMrUwHP5ZxcHp+5kYk=@vger.kernel.org X-Gm-Message-State: AOJu0Yzd9ZKW0LEFAQ6ne/pNWaBR7Hf5y0tTt4JZJHNW69wLO4Cjvuvj /aX5PYWlTbMXvpWtlQy0Lq/qxaEGycKSMhsTy86qariJ0P1+bdXt/tUqutyEiV/MnBIV9wYe91Y TPvFU2Fe9lfvMXP2F0PBeh3wufIdz3Q== X-Gm-Gg: Acq92OELXdSJajo8v6SvrH46NuFsJGirRwBBDBmGI+iht5le42oxc3NC2VLs750EDEn MVnfZToDDjO+8T06OnDq+VDCFKbXccfItDkc/N8cFMvoqi9L2mLujQklVf8tfdvFt6UHdJqSfTh wsOfRepRxdOyNJ34iwFdg5NUllxk4RCQcB+9Yc9uucPke5mhtK5szHpJ1G78sIagU8nEDbLI8GM kagWholp10J66KC7q10T62LpQqRWgGS4My98yuXUlglSbBdBSx/XbQGVZ3YZMrEvghjiyzIBdAR tuTIacKHgjwMtv/CbH0assDNjMvdxtaBVJZNRASWRsv+ylSNww== X-Received: by 2002:a05:6402:40c5:b0:683:e394:cc0c with SMTP id 4fb4d7f45d1cf-68c11067377mr33691a12.4.1780006308002; Thu, 28 May 2026 15:11:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260528-nfsd-fixes-v1-0-e78708eff77d@kernel.org> <20260528-nfsd-fixes-v1-9-e78708eff77d@kernel.org> In-Reply-To: <20260528-nfsd-fixes-v1-9-e78708eff77d@kernel.org> From: Rick Macklem Date: Thu, 28 May 2026 15:11:35 -0700 X-Gm-Features: AVHnY4Lbwdzqwlt08lzqkvusST2UOxk56g2nR4DTwa0MUqGV4xq3-56ZUni36Vs Message-ID: Subject: Re: [PATCH 09/10] nfsd: cap decoded POSIX ACL count to bound sort cost To: Jeff Layton Cc: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Scott Mayhew , Trond Myklebust , Andreas Gruenbacher , Mike Snitzer , Rick Macklem , Chris Mason , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 28, 2026 at 2:56=E2=80=AFPM Jeff Layton wr= ote: > > CAUTION: This email originated from outside of the University of Guelph. = Do not click links or open attachments unless you recognize the sender and = know the content is safe. If you are unsure, forward the message to ITHelp@= uoguelph.ca for review. > > > From: Chris Mason > > nfsd4_decode_posixacl() reads a u32 entry count off the wire and passes > it straight to posix_acl_alloc() and sort_pacl_range(). The latter is > an O(n^2) bubble sort, so a client-chosen count drives unbounded CPU in > the server's compound processing path. > > nfsd4_decode_posixacl() > xdr_stream_decode_u32(&count) /* uncapped u32 */ > posix_acl_alloc(count, GFP_KERNEL) > sort_pacl_range(*acl, 0, count - 1) /* O(n^2) bubble sort */ > > The encoder side in the same file already rejects ACLs whose a_count > exceeds NFS_ACL_MAX_ENTRIES, but the decoder introduced in commit > 5fc51dfc2eb1 ("NFSD: Add support for XDR decoding POSIX draft ACLs") > omitted the symmetric check. My recollection is that Chuck didn't like this limit. He argued that it was specific to the NFSv3 ACL protocol and that the limit on the size of a NFSv= 4 RPC message was sufficient. I, personally, think that 1024 is a reasonable limit for # of ACEs, but Chuck can jump in here if he doesn't agree. (Note that, if user/groups are configured as "#s in the string", a lot of A= CEs fits in a 4Mbyte RPC message and the server file system will also set a lim= it although, as you note, that happens after the sort.) The good news w.r.t. the sort is that they are normally already sorted, so the bubble sort is normally just a single pass, I think? rick > > Fix by rejecting a wire count greater than NFS_ACL_MAX_ENTRIES with > nfserr_resource, before any allocation, so the sort is bounded by > NFS_ACL_MAX_ENTRIES^2 comparisons. > > Fixes: 5fc51dfc2eb1 ("NFSD: Add support for XDR decoding POSIX draft ACLs= ") > Assisted-by: kres:claude-opus-4-7 > Signed-off-by: Chris Mason > --- > fs/nfsd/nfs4xdr.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index c6c50c376b23..5469c6c207ba 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -448,6 +448,8 @@ nfsd4_decode_posixacl(struct nfsd4_compoundargs *argp= , struct posix_acl **acl) > > if (xdr_stream_decode_u32(argp->xdr, &count) < 0) > return nfserr_bad_xdr; > + if (count > NFS_ACL_MAX_ENTRIES) > + return nfserr_resource; > > *acl =3D posix_acl_alloc(count, GFP_KERNEL); > if (*acl =3D=3D NULL) > > -- > 2.54.0 >