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=1796495971; b=lr8CQv/V/2WzaK64kzHBeWWSGWQLBLy1Yk/4/IJftlaA/5UHUFuy48QPgdCJTyeONqGj mzNemEsYGOFdiMla3yXuyIAPC0xSI/IhHVumrL/o0psmO3jNA6CWMrYh/HsEhiUKuWUyy TTh1bB9SwDkyYYqRv1ntEL/3Qc9mJO1XyW2KQIGTNLX20H8nu2qpWyXKJU3VU/zDDJyGJ ezEaT0RuP1gfd6ixCdw8NJ2k6kH0zwvcr7ZnKseLVv0KV9pxS/i6CT6EABZxX9kIlEWyI 6BwMNZv7SNpB4Rg6b/bsfnSQm5bT44eOZ6TY1mAuS1OPq1dBzRWoXB/ZyQoCitzxgmw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796495971; 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=h4mXXX5Sy41QDk+LwQFBY9P9w823vcCNoNczQUDBDVg=; b=aFaHjwBS8j8fU/XiQa80vOy+BduhohK9NoH2xBhuy8/96VgN4Ae6FM8A0aYntpu92bF5 VzwgifWy6eZ4C/qUhby/+2JzEEdfpJ7VYgD2sTHDLOQlA+IutYSC1YxbHdvD7ZjaJ+U5Z vrrxM8TfnhyBnl7OTPW0PweZLCgL7KanI4cJ3w2X/HeXXN3fV1XbNWav376xgErO4nrwd XH1dErlyP58Csjdq4cDlNk6/UKRX6QKjbzM4YxC0mLmiWtd/9HqLllDnlJM++Y50hwWDX 8zuwaOvM0FpixMA5xELcIwtULxj7pV+F+obhaS3i6otX0vMsV7mypUHw6c0xolrcpyQ== 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=kBUXhLSS; 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 76264606A333 for ; Sat, 5 Dec 2026 18:39:31 +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=kBUXhLSS Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2FBF1F00A07; Sat, 5 Dec 2026 18:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796495971; bh=h4mXXX5Sy41QDk+LwQFBY9P9w823vcCNoNczQUDBDVg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=kBUXhLSS/vuD/l206gHJzmYEivuk9ZBl1R7+NLDY0rsyooH3HKcMgS/JMHD4Tzf9O pF+FpccYF2NEgUwRJ8nX0HIlwPNoen7vdEqJ0K1pmVr4QsZ/UNNxQa3qaKpR33g7z8 azf7cqUAbu6pJ9ILlecNTLMyF9DHN8xj9g4RW45MPAlhr/L5AebKvZme9s1mMA3lyX icjILtd8HEiYPNa36jkJeD/b3eEi08HQb9e8W2WetuLS32hjI9lhQ8q87uXWk+5U6B 3+riU7H2ZaouV3eCcl49xBaA4JP00sv7vhu6ttFhiegPilD9okxOa0ol1PauTslMI6 +BpO2zOS/2HiQ== From: Chuck Lever Date: Sat, 05 Dec 2026 13:39:20 -0500 Subject: [PATCH v2 1/5] SUNRPC: Fix integer overflow in gss_unwrap_resp_integ() bounds check 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-1-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=1399; i=cel@kernel.org; h=from:subject:message-id; bh=BV//xinbSytrWizp1uFsmvU3GAmBltf7PEvFwEYLPtE=; b=owEBbQKS/ZANAwAKATNqszNvZn+XAcsmYgBrFFpgDCHvKLjyK83VaH6O+eeHb/XuapTUFdnUC kC1JT4ezVCJAjMEAAEKAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCaxRaYAAKCRAzarMzb2Z/ l1YKD/44AdVSQW3UNfMcQYfTRxSMX5YbencANrRjisTJt8/y70NSH/rrY/AZJmmI6dx8DJRkfYa h1I1LXxub4xohOS42/fOKEyQcc52jDMLIdYKehT0JNemv+hQizxXoOAR4mMA/AqXL+d9dfDZ6fG RiN9zszyqauKan9zdCmuptOv2Zvsb4FXJ6QNLA+Cll5BpkE2KmC/Jyr7bp+hfAGz9BFvhkOgzoC iCBFCqseETA77garL7Jbt2aFz352nPwRAoi7WkAMWY2akMSjONegWb6a/V6aoK4l9hfq5gaD5KG aroZ6oPJIvbl9TlOfPRG2ev+cHqEyCejWhx45nSEvqhyBUmH63CCgFkU8vDuuDOLBl0UcJVnL1u M5ncWFnUsRCv77ATO0wrw+5/9JfLEGlC65JDosweF8DzffUcnGX9ZQhO6Er5TG+gCsDeQi+Mix1 hm8tEw2xNrFpr089zidzRm01UY6JIVEQMHzFNt5Q6/qe6W0ZjqzpyDaiD7kAdCKXLM4BeEDZf/y gtVxG4dRArojGdYWSb/y2FXgTNxSd0CnI75/Uvs4xTu6iR8PnSmVjfMkQQnW98jDv62C23PRW3q JGMlMth6zrL9bMfQLMltWJj+F+vbc4l8vWurBLwYQVraFfZDkV5wt2aTUPkgdoUcWIPAevpz8Xp /Z4GwJtGIXAEEog== X-Developer-Key: i=cel@kernel.org; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 gss_unwrap_resp_integ() reads the length of the reply checksum before anything has verified that length. The bounds check adds the length to an offset in 32 bits, so a value close to U32_MAX wraps the sum and passes. kmalloc() then warns about the oversized request. The warning panics an NFS client running with panic_on_warn. A faulty server, or anyone able to modify replies, can send such a length. Compare the length with the space left in the receive buffer. Check the offset first, because xdr_decode_word() does not limit reads to rcv_buf->len and the subtraction could otherwise underflow. 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, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 8ddc65e894da..50b8503d3a12 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -2024,7 +2024,7 @@ 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 (offset + len > rcv_buf->len) + if (offset > rcv_buf->len || len > rcv_buf->len - offset) goto unwrap_failed; mic.len = len; mic.data = kmalloc(len, GFP_KERNEL); -- 2.56.0