sunrpc: close length validation gaps in krb5p unwrap
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | SUNRPC: svcauth_gss: enforce krb5 token minimum lengthnet/ | +2 | 0 replies | |
| 2/4 | SUNRPC: harden gss_unwrap_resp_priv length checksnet/ | +5 | 0 replies | |
| 3/4 | SUNRPC: xdr_buf_trim: clamp buf->len to avoid underflownet/ | +1 | 0 replies | |
| 4/4 | SUNRPC: harden gss_krb5_unwrap_v2 against short tokensnet/ | +9 | 0 replies |
Reviews trailers per patch
None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Jeff Layton |
|---|---|
| Series | R-b |
| 1/4 | |
| 2/4 | |
| 3/4 | |
| 4/4 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/4] sunrpc: close length validation gaps in krb5p unwrap
From: Chuck Lever <[email protected]>
Neither svcauth_gss_unwrap_priv() nor gss_unwrap_resp_priv() enforces a minimum on the wire-supplied opaque length before forwarding it to the krb5 unwrap core. An authenticated krb5p peer -- NFS client or server -- can send a token shorter than the 16-byte RFC 4121 header and reach gss_krb5_unwrap_v2() with a length that drives pre-decrypt out-of-bounds reads, a divide-by-zero in _rotate_left(), and a post-decrypt unsigned underflow in the movelen computation that feeds a multi-gigabyte memmove.
The fixes are layered so that neither the caller boundary nor the unwrap core depends on the other for safety. The caller-side floor checks (patches 1, 2) are sufficient to close the attack, but gss_krb5_unwrap_v2() must also be self-defending because it is reachable through gss_unwrap() from any future caller that might not enforce the same floor. The xdr_buf_trim() clamp (patch 3) is independent of krb5 -- it corrects a generic invariant violation that gss_krb5_unwrap_v2() happens to be the only current trigger for, but that any caller could hit if buf->len and the component iov_lens get out of sync.
The client side (patch 2) has an additional u32 integer-overflow bypass that the server side does not: the original offset + opaque_len > rcv_buf->len wraps when opaque_len is near UINT_MAX, accepting a huge token length that re-enters the same underflow chain. The replacement splits the check into separate offset and length guards that are safe in u32 arithmetic.
Chris Mason (4):
SUNRPC: svcauth_gss: enforce krb5 token minimum length
SUNRPC: harden gss_unwrap_resp_priv length checks
SUNRPC: xdr_buf_trim: clamp buf->len to avoid underflow
SUNRPC: harden gss_krb5_unwrap_v2 against short tokens
net/sunrpc/auth_gss/auth_gss.c | 6 +++++- net/sunrpc/auth_gss/gss_krb5_wrap.c | 11 +++++++++-- net/sunrpc/auth_gss/svcauth_gss.c | 2 ++ net/sunrpc/xdr.c | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-)
Signature · 1 line
2.54.0