Netdev List
 help / color / mirror / Atom feed
* [PATCH] rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response()
@ 2026-11-27 12:52 Bilal Hashim
  2026-11-27 12:58 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Bilal Hashim @ 2026-11-27 12:52 UTC (permalink / raw)
  To: David Howells, Marc Dionne; +Cc: linux-afs, netdev, linux-kernel, Bilal Hashim

In rxgk_construct_response(), the buffer length calculation forgets to
round up both `appdata->len` and `authx_len` to 4-byte XDR boundaries:

1. `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)`. When userspace
   supplies a non-4-byte-aligned `RXRPC_RESP_RXGK_APPDATA` control
   message, the allocated authenticator buffer is up to 3 bytes too
   short, causing `skb_store_bits()` / `crypto_krb5_encrypt()` to fail
   or hit `WARN_ON()` in `crypto_krb5_encrypt()`.
2. `len` uses `(4 + authx_len)` instead of `(4 + xdr_round_up(authx_len))`,
   even though `rxgk_pad_out()` subsequently writes up to 3 trailing XDR
   padding bytes after `authx_offset + authx_len`.

Wrap both `appdata->len` and `authx_len` in `xdr_round_up()`.

Signed-off-by: Bilal Hashim <AeeSec@126.com>
---
--- 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] 2+ messages in thread

end of thread, other threads:[~2026-11-27 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 12:52 [PATCH] rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response() Bilal Hashim
2026-11-27 12:58 ` netdev-bot+sinfo

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