From: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>
To: cel@kernel.org, jlayton@kernel.org, trondmy@kernel.org, anna@kernel.org
Cc: linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>
Subject: [PATCH v2] SUNRPC: restrict integrity replies to authenticated payload
Date: Sun, 20 Sep 2026 21:07:13 +0000 [thread overview]
Message-ID: <20260920210712.2887738-2-Jeremy.Jean@oss.cyber.gouv.fr> (raw)
gss_unwrap_resp_integ() authenticates only databody_integ. The checksum
object and any bytes after it are not covered by the integrity check, but
remain visible to the XDR decoder.
This makes RPCSEC_GSS reply payloads malleable by bypassing crypto
integrity. A modified reply can contain only the RPCSEC_GSS sequence
number in databody_integ, reuse the reply verifier MIC as the body MIC,
and append bytes that the decoder consumes without invalidating the MIC.
Decode the checksum length into mic.len and truncate the decode stream
after MIC verification so only the authenticated payload remains visible.
Reject bodies shorter than the mandatory sequence number before using the
body length.
Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
Assisted-by: Codex:gpt-5
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
Changes in v2:
- Drop the redundant xdr_stream_remaining() guard before truncation.
v1: https://lore.kernel.org/all/20260919212024.2335794-2-Jeremy.Jean@oss.cyber.gouv.fr/
net/sunrpc/auth_gss/auth_gss.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 8ddc65e894da..b4911b6e69cc 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -2001,7 +2001,7 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred,
/* opaque databody_integ<>; */
if (xdr_stream_decode_u32(xdr, &len))
goto unwrap_failed;
- if (len & 3)
+ if (len < XDR_UNIT || len & 3)
goto unwrap_failed;
offset = rcv_buf->len - xdr_stream_remaining(xdr);
if (xdr_stream_decode_u32(xdr, &seqno))
@@ -2021,13 +2021,12 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred,
/* opaque checksum<>; */
offset += len;
- if (xdr_decode_word(rcv_buf, offset, &len))
+ if (xdr_decode_word(rcv_buf, offset, &mic.len))
goto unwrap_failed;
offset += sizeof(__be32);
- if (offset + len > rcv_buf->len)
+ if (offset + mic.len > rcv_buf->len)
goto unwrap_failed;
- mic.len = len;
- mic.data = kmalloc(len, GFP_KERNEL);
+ mic.data = kmalloc(mic.len, GFP_KERNEL);
if (ZERO_OR_NULL_PTR(mic.data))
goto unwrap_failed;
if (read_bytes_from_xdr_buf(rcv_buf, offset, mic.data, mic.len))
@@ -2039,6 +2038,10 @@ gss_unwrap_resp_integ(struct rpc_task *task, struct rpc_cred *cred,
if (maj_stat != GSS_S_COMPLETE)
goto bad_mic;
+ /* Expose only the authenticated payload to the decoder. */
+ xdr_truncate_decode(xdr, xdr_stream_remaining(xdr) -
+ (len - XDR_UNIT));
+
gss_update_rslack(task, cred, 2, 2 + 1 + XDR_QUADLEN(mic.len));
ret = 0;
--
2.47.3
next reply other threads:[~2026-09-20 21:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 21:07 Jérémy Jean [this message]
2026-09-21 13:27 ` [PATCH v2] SUNRPC: restrict integrity replies to authenticated payload Chuck Lever
2026-09-22 15:50 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260920210712.2887738-2-Jeremy.Jean@oss.cyber.gouv.fr \
--to=jeremy.jean@oss.cyber.gouv.fr \
--cc=anna@kernel.org \
--cc=cel@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=trondmy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox