Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796495974; b=XHiekmLk0Z9vQvZhWhsZvcXdKTonk1sTirIGEge+TWLKW0oFIcXwx2RtQWFt5zOnoJZn 7WM7aaC4fFmTwf8wgZ/QcJXFMO4m10kMKIwAmQtgGnbSsC8auVTC6Sm3RWiZUWDm+iupF sH9G+Trxm5IIq71Z7raHEg3ZbcPnYl0oF3JSa8HEjlTb7GySK2iO28GiHJt9zTQP1oUj5 7rmsTvUOfbWK/kGav9TBn8LzaLYCk85OQ63MyfxIof/lc02A1YGVPC8wEIqmarNaalHDR MkWT5TfipCyYGX6pz1qWtQIbDaeC0GASu+hafEmqhQV3ZtNol/P1EuRbddsSNGNbPyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796495974; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=jFGwGSxTj/pPV8WUpnvtvGhhjseJ0RfTthsy96ZJzDg=; b=jQ8HcLUYeDb0fMh3rIWHJRKE6xeVJ3s86v4acBzyvyBMMkdBMacfos84jtzPyAPL02O/ czZjQ7E0ljuB7xXy7eRGKIrAX6v3KdMXjSAxgc8KH/6+RCgGP/CzwVfgH4CtXESbc4/+r P4jhQqTpeku9yrmL8GAxKzng8G8CpOD2TG7/r5P9mmIL3KnarM7k4L3+XPcZdUzfzWRT6 0o7JobweQPhbQzQaM8aOZgKMeqM4hmLxRfV5HjiYqL5S+GdZC5uNWuKwedEBhjOqsPMKa 9VtX6oWC0SV6Rvoju9dp6gVBrKu+MG/wHWuLilUKv7RY6Ye6AY0W9vF6vxAHOF/ujAg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jTzkbEwz; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0738606A31F for ; Sat, 5 Dec 2026 18:39:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jTzkbEwz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 648501F0092B; Sat, 5 Dec 2026 18:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796495974; bh=jFGwGSxTj/pPV8WUpnvtvGhhjseJ0RfTthsy96ZJzDg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jTzkbEwzOwBRDsEuo441M3MxHFdJ4JlWWut4rYxB9Ma07TxU9hz3tnOeBI+7WdiBH eS3rUvI7Xmtsq71E0mIeNgWwQOxXQQqpoL6tNJIQuY3sozP2H5dGdqeoIHDkC+ROGe h12QSbdmgrTIA/ip1OP0rQEOaG8KF/TCAidft+r3Yb1Ev1mzfc0VwXmmY2ZVzMdTvm YKc4UyN0gmLs15VcFowORBmoVbbWHPsWSxbBLhrHlKGf/YK54cd3yCJrL7Y+G8tmOq NpDZ9M5NGmBbcdaDIAxxzi9gFctYbRjnuRORobsZE2ynaLqPnrNc3uCM73N0DfuOmw A6ShSQK/c2hyQ== From: Chuck Lever Date: Sat, 05 Dec 2026 13:39:23 -0500 Subject: [PATCH v2 4/5] SUNRPC: Limit the size of a GSS reply checksum 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261205-gss-stale-reply-v2-4-c9e745261524@kernel.org> References: <20261205-gss-stale-reply-v2-0-c9e745261524@kernel.org> In-Reply-To: <20261205-gss-stale-reply-v2-0-c9e745261524@kernel.org> To: Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: linux-nfs@vger.kernel.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1358; i=cel@kernel.org; h=from:subject:message-id; bh=9vC5LD0QOPymE7OPo46/BRkEWY+XYbk/9msyvAJLJQg=; b=owEBbQKS/ZANAwAKATNqszNvZn+XAcsmYgBrFFpgDsjBGZXkBEmOxgVfwX8ZqRyFv5lpkrg25 jptwq5YsCGJAjMEAAEKAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCaxRaYAAKCRAzarMzb2Z/ l8jwD/4maJGyYEtr/kJd7KvIb+yJty4JtfOrqi8qCMnkRveFVShuuGmvthJeSKYhY8BlNUm2BtQ DEKILNmbsNedVA5edlCtyDCwzr4l++Vl62SyzNuqOkGn2z/CRMrIqpdzfzPPmPH5IbAsTfEr13H Sb6aPZ8AETjRoxaZa+CCi2/OLSu3lcK1maxKgjNfPetBQYZ/Or8Jaa8PbL9vYI1v+5grsLXmrGd XHmMKX00RByJEqktCzz5osMN2g3m+TlAbpofvrOn9k9WIB3bLjTKH6ukdkNZOfCCtdHi1resUT7 IJ1FKJpjb2ZtbHv9hdhZbWCz8hcTbLpVS/N0JlmJ6yQQYqjQ8rrnNRfDGzI621jg6jIipzvbW7o 3TOMfl/a8DHw+pcWDSR4SxwZ5H2QPCwtBwwS/aZjfcCXsp7RqpCOn2acDHcGm28P0aq7nGuSl13 OA2UfNNAoWDTgvgpFEJO++eSRuidzNsmug93KH0PYPWrAFNiOGPnsC+1RJ3GcXD/hjaIm4HzrRu 3NqtiCq7YzscC5U7unahYX/h6Xz/eN5B/704P9V0L/RbLriLI2JsKa8OaemaspuDJIJdUgaDqTy sxu8onDFr8Au0arsNpgZdbEyW80Xlp58dRKz5fS6VWMHVd4SMMHxuGNY5d1n91NzyK0BdNpBbfJ XIPhXmJykk3Ct5w== X-Developer-Key: i=cel@kernel.org; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 gss_unwrap_resp_integ() passes the length of the reply checksum to kmalloc() before anything has verified the reply body. The only limit is the space left in the receive buffer. On a large READ, a faulty server, or anyone able to modify replies, can make the NFS client attempt a contiguous allocation of nearly the size of the reply. Reject a checksum longer than RPC_MAX_AUTH_SIZE, which is the limit gss_validate() applies to the MIC in the reply verifier. Both are MICs from the same GSS context, and gss_validate() runs first, so a mechanism with larger tokens would already fail there. Fixes: 4047aa909c4a ("sunrpc: Fix gss_unwrap_resp_integ() again") Signed-off-by: Chuck Lever --- net/sunrpc/auth_gss/auth_gss.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 57759fd96956..55adad44d381 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -2029,6 +2029,8 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred, if (xdr_decode_word(rcv_buf, offset, &len)) goto unwrap_failed; offset += sizeof(__be32); + if (len > RPC_MAX_AUTH_SIZE) + goto unwrap_failed; if (offset > rcv_buf->len || len > rcv_buf->len - offset) goto unwrap_failed; mic.len = len; -- 2.56.0