From: Bilal Hashim <AeeSec@126.com>
To: David Howells <dhowells@redhat.com>,
Marc Dionne <marc.dionne@auristor.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
linux-afs@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Bilal Hashim <AeeSec@126.com>,
stable@vger.kernel.org
Subject: [PATCH net v2] rxrpc: rxgk: round up appdata and authx lengths in rxgk_construct_response()
Date: Sat, 28 Nov 2026 22:03:23 +0800 [thread overview]
Message-ID: <20261128140323.1122-1-AeeSec@126.com> (raw)
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)
reply other threads:[~2026-11-28 14:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261128140323.1122-1-AeeSec@126.com \
--to=aeesec@126.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.