From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796379588; b=mRrZajIrrDabQMJ9NYAigw471JhLj038j+HepY0sD4Bo1Q4QlZE7mDyqx/Lck8WrYvc2 FBJfQaWbPLPYHvpE7TwTvTqAHUCpNHX4L/WbyjUdvKQ9JjY2pDnWj1OpKqhT+AHYmduSy DPWqvFP9dhVrGEREl1w7IXDqjQYne1RTimS7XKM9OoN6CTY5UUL219yurjFV+BJd9gIFE Zh+6aQenZ3VEzyVCXt8XaFsTyppGpvNQVI4OKwPi3UCZzc5Gx+FzozXrpMiMYEFkeaXs7 kATVZeU7PPqqO3Lp8dFYnBfWVaQSMzUtdnM5S1kf3E/hutfLdlQ41aH2wiPC6iNgUtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379588; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Gmg+Bl23GzWF1lC6kJM3TgHmnSmXLECCk94ba3fh1wo=; b=dqmrLm6yN0+OF0Z+MYuL/3sah1ZodF3OXq1GHWeq4pfUsG41VBB0xqK1Uiqu2LX1kgzd gq7CAechPNyC4ax/dt9ITu/PUX5XgmOEXYC3wOdU+uCpEPwhclQpCwhq8Dj3FOED70jPG tUxYzqLKrqRJ2UhXbsKqMyB08TQEB0sqauYn5uio2bcBiUm0+Kqg1eYLujB913ywfB9Zx r2fwBMATt+dT/MHis41MfnecsW1EGIzl1pXpkbpmX6ZfyXRCNo2X1vAA0C5Njyn4XKr3k olu5BwUMWj2mnJISAMEhzEg//BCcUqWsXHmcINjUDbAFKcWwhs1LI/MIZ/WqIOPwsKw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jeEykj74; 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 9C73D606A683; Fri, 4 Dec 2026 10:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jeEykj74 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12DDB1F00897; Fri, 4 Dec 2026 10:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379588; bh=Gmg+Bl23GzWF1lC6kJM3TgHmnSmXLECCk94ba3fh1wo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jeEykj74huQAxgi6z6Qlf/KfjKskRxuxloBIkfAAMZtOVrQ8c3aLMvzCUYC3gCvsl XTR3W0jCd06N/NDx6DTnK5XX2M1yvZVirABhoBb4doNrSdoKtHdKnr3rsFzgTd0GLH 8u1qYB4YT+DE+a9xhJgerY4Oar7F0qjH2gHleDxs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 6.1 0012/1059] SUNRPC: svcauth_gss: enforce krb5 token minimum length Date: Fri, 4 Dec 2026 18:52:23 +0900 Message-ID: <20261204100644.332668457@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason [ Upstream commit a919c5c88769cf8fb3ec071e6078d830bf512489 ] svcauth_gss_unwrap_priv() validates only an upper bound on the wire-supplied opaque length before handing the buffer to gss_unwrap(): if (len > xdr_stream_remaining(xdr)) goto unwrap_failed; offset = xdr_stream_pos(xdr); ... maj_stat = gss_unwrap(ctx, offset, offset + len, buf); The wire value `len` flows unchanged as the upper bound into the krb5 unwrap path, so a len in [0, 16] passes this check and is handed to gss_unwrap(). For a krb5 v2 context that lands in gss_krb5_unwrap_v2(), which reads the 16-byte RFC 4121 token header fields at ptr+4 and ptr+6 and then calls rotate_left() before any integrity check. With a sub-header length the header reads run past the token, and _rotate_left()'s `shift %= buf->len` path can divide by zero when buf->len has been driven to zero by the truncated token. A header-only token (len == 16) is equally invalid: with a non-zero RRC field and the opaque blob ending at the XDR buffer boundary, rotate_left() builds a zero-length subbuffer, reaching the same division. Reject the token at the server entry point before it reaches the krb5 unwrap core. A valid sealed RFC 4121 token must contain the 16-byte header plus at least some encrypted payload. Fix by adding a minimum-length check immediately after the existing upper-bound check: if (len <= GSS_KRB5_TOK_HDR_LEN) goto unwrap_failed; Fixes: 7c9fdcfb1b64 ("[PATCH] knfsd: svcrpc: gss: server-side implementation of rpcsec_gss privacy") Cc: stable@vger.kernel.org Assisted-by: kres (claude-opus-4-7) Signed-off-by: Chris Mason Reviewed-by: Jeff Layton Link: https://patch.msgid.link/20260524010213.557424-2-cel@kernel.org Signed-off-by: Chuck Lever [ sashal: Kept the older pre-xdr_stream code and inserted the two-line len <= GSS_KRB5_TOK_HDR_LEN check after the existing len > remaining_len check, since upstream's xdr_stream context lines don't exist. ] Signed-off-by: Sasha Levin --- net/sunrpc/auth_gss/svcauth_gss.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 64fba16d8afc1..cc92e28c1a27d 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -1022,6 +1022,8 @@ svcauth_gss_unwrap_priv(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, remaining_len = total_buf_len(buf); if (len > remaining_len) goto unwrap_failed; + if (len <= GSS_KRB5_TOK_HDR_LEN) + goto unwrap_failed; pad = remaining_len - len; buf->len -= pad; fix_priv_head(buf, pad); -- 2.53.0