[PATCH] rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response()
From: Bilal Hashim
Date: Fri Nov 27 2026 - 07:54:10 EST
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@xxxxxxx>
---
--- 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)