Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2] rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response()
@ 2026-11-28 14:03 Bilal Hashim
  0 siblings, 0 replies; only message in thread
From: Bilal Hashim @ 2026-11-28 14:03 UTC (permalink / raw)
  To: David Howells, Marc Dionne
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, linux-afs, netdev, linux-kernel, Bilal Hashim,
	stable

In rxgk_construct_response(), `auth_len` is computed using `appdata->len`
instead of `xdr_round_up(appdata->len)`, while
rxgk_construct_authenticator() pads `appdata` to
`xdr_round_up(appdata->len)` bytes and returns
`sizeof(a) + xdr_round_up(appdata->len) + sizeof(b)`.

Userspace can supply an unaligned `RXRPC_RESP_RXGK_APPDATA` control
message via sendmsg() -> rxgk_sendmsg_respond_to_challenge(), which
copies `cmsg->cmsg_len - sizeof(struct cmsghdr)` into `appdata.len`
without checking 4-byte alignment. When `appdata->len` is not a multiple
of 4, the allocated scatterlist length (`sg_len`) is up to 3 bytes too
short, causing the profile encryption routine (krb5_aead_encrypt() or
rfc8009_encrypt()) to hit `WARN_ON(cksum_offset + krb5->cksum_len >
sg_len)` and return -EFAULT, preventing the RESPONSE packet from being
sent (and panicking systems with panic_on_warn).

As defensive hardening, also wrap `authx_len` in `xdr_round_up()` when
computing the total `len` to match the subsequent `rxgk_pad_out()` call,
even though all currently supported enctypes already produce a 4-byte
aligned `authx_len`.

Found by manual code inspection (not reproduced at runtime; verified via
call-chain analysis from sendmsg() -> rxgk_sendmsg_respond_to_challenge()
-> rxgk_construct_response() -> crypto_krb5_encrypt()).

Fixes: 9d1d2b59341f ("rxrpc: rxgk: Implement the yfs-rxgk security class (GSSAPI)")
Cc: stable@vger.kernel.org
Signed-off-by: Bilal Hashim <AeeSec@126.com>
---
Changes in v2:
- Add Fixes: tag and Cc: stable@vger.kernel.org.
- Clarify the exact WARN_ON() site (krb5_aead_encrypt() /
  rfc8009_encrypt()), describe the `xdr_round_up(authx_len)` hunk as
  defensive hardening, and note how the issue was discovered.
---
--- a/net/rxrpc/rxgk.c
+++ b/net/rxrpc/rxgk.c
@@ -936,11 +936,12 @@ static int rxgk_construct_response(struct rxrpc_connection *conn,
 	if (IS_ERR(gk))
 		return PTR_ERR(gk);
 
-	auth_len = 20 + (4 + appdata->len) + 12 + (1 + 4) * 4;
+	auth_len = 20 + (4 + xdr_round_up(appdata->len)) + 12 + (1 + 4) * 4;
 	authx_len = crypto_krb5_how_much_buffer(gk->krb5, KRB5_ENCRYPT_MODE,
 						auth_len, &auth_offset);
 	len = sizeof(struct rxrpc_wire_header) +
-		8 + (4 + xdr_round_up(gk->key->ticket.len)) + (4 + authx_len);
+		8 + (4 + xdr_round_up(gk->key->ticket.len)) +
+		(4 + xdr_round_up(authx_len));
 
 	response = alloc_skb_with_frags(0, len, 0, &ret, GFP_NOFS);
 	if (!response)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-28 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 14:03 [PATCH net v2] rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response() Bilal Hashim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox