Re: [PATCH] rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response()

From: netdev-bot+sashiko

Date: Sat Nov 28 2026 - 08:46:06 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The commit message has no Fixes: tag and no Cc: stable, but
the patch fixes a bug that userspace can trigger.
- [Low] The commit message gets three details of the failure wrong.

--

rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response()

This patch fixes the RESPONSE buffer length calculation in
rxgk_construct_response(). auth_len now uses xdr_round_up(appdata->len),
which matches the size rxgk_construct_authenticator() writes. The authx
part of len is now rounded up with xdr_round_up(authx_len).

> 1. `auth_len` is computed using `appdata->len` instead of

[ ... ]

> 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`.

[Severity: Low]
Is this description accurate? A few details don't seem to match the code.

Can skb_store_bits() actually fail here? rxgk_construct_authenticator()
writes up to authx_offset + conf_len + 56 + xdr_round_up(appdata->len).
Even before this patch, the skb extended to authx_offset + conf_len + 56 +
appdata->len + cksum_len.

The padding is at most 3 bytes. cksum_len is at least 12 for every
supported enctype (rfc3962: 12, rfc6803: 16, rfc8009: 16/24). So every
store appears to fit.

The WARN_ON() that fires also isn't the one in crypto_krb5_encrypt(). It
is the one in the profile encrypt routine, either krb5_aead_encrypt() in
crypto/krb5/rfc3961_simplified.c or rfc8009_encrypt() in
crypto/krb5/rfc8009_aes2.c:

if (WARN_ON(cksum_offset + krb5->cksum_len > sg_len))
return -EFAULT;

For item 2, can rxgk_pad_out() write any padding after authx_offset +
authx_len? After encryption, authx_len is conf_len + auth_len + cksum_len:

- conf_len is 16.
- auth_len is sizeof(a) + xdr_round_up(appdata->len) + sizeof(b), which
is always 4-aligned.
- Every cksum_len is a multiple of 4.

That means rxgk_pad_out(response, authx_len, ...) always pads 0 bytes, and
xdr_round_up(authx_len) equals authx_len for every supported enctype.

Should the message describe the second hunk as hardening rather than a
second bug fix?

> diff --git a/net/rxrpc/rxgk.c b/net/rxrpc/rxgk.c
> index 77a67ace1d248..6dc4bfd2445a3 100644
> --- 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));

[Severity: Medium]
Both of these calculations came from commit 9d1d2b59341f ("rxrpc: rxgk:
Implement the yfs-rxgk security class (GSSAPI)"). Should this patch carry a
Fixes: tag for that commit, and possibly a Cc: stable?

Userspace can reach this with sendmsg(). rxgk_sendmsg_respond_to_challenge()
takes the appdata length from the cmsg without checking alignment:

appdata.len = cmsg->cmsg_len - sizeof(struct cmsghdr);

The call chain is:

sendmsg()
rxgk_sendmsg_respond_to_challenge()
rxgk_construct_response()
rxgk_encrypt_authenticator()
crypto_krb5_encrypt()
krb5_aead_encrypt() / rfc8009_encrypt()

If appdata->len is not a multiple of 4, rxgk_construct_authenticator()
returns 56 + xdr_round_up(appdata->len). Before this patch, sg_len was only
conf_len + 56 + appdata->len + cksum_len. The WARN_ON() in the encrypt
routine therefore always fires and returns -EFAULT.

The result is a WARN that userspace can trigger at will (a panic with
panic_on_warn), and the RESPONSE is never sent. Without a Fixes: tag,
stable trees that include rxgk (6.16 onwards) might not pick up this fix.

>
> response = alloc_skb_with_frags(0, len, 0, &ret, GFP_NOFS);
> if (!response)

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127125250.1434-1-AeeSec%40126.com