linux/net/sunrpc/auth_gss
Chuck Lever 5f24a8725f SUNRPC: Fix a crash in gss_krb5_checksum()
Anna says:
> KASAN reports [...] a slab-out-of-bounds in gss_krb5_checksum(),
> and it can cause my client to panic when running cthon basic
> tests with krb5p.

> Running faddr2line gives me:
>
> gss_krb5_checksum+0x4b6/0x630:
> ahash_request_free at
> /home/anna/Programs/linux-nfs.git/./include/crypto/hash.h:619
> (inlined by) gss_krb5_checksum at
> /home/anna/Programs/linux-nfs.git/net/sunrpc/auth_gss/gss_krb5_crypto.c:358

My diagnosis is that the memcpy() at the end of gss_krb5_checksum()
reads past the end of the buffer containing the checksum data
because the callers have ignored gss_krb5_checksum()'s API contract:

 * Caller provides the truncation length of the output token (h) in
 * cksumout.len.

Instead they provide the fixed length of the hmac buffer. This
length happens to be larger than the value returned by
crypto_ahash_digestsize().

Change these errant callers to work like krb5_etm_{en,de}crypt().
As a defensive measure, bound the length of the byte copy at the
end of gss_krb5_checksum().

Kunit sez:
Testing complete. Ran 68 tests: passed: 68
Elapsed time: 81.680s total, 5.875s configuring, 75.610s building, 0.103s running

Reported-by: Anna Schumaker <schumaker.anna@gmail.com>
Fixes: 8270dbfceb ("SUNRPC: Obscure Kerberos integrity keys")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2023-03-22 16:58:26 -04:00
..
auth_gss_internal.h SUNRPC/auth_gss: Convert GFP_NOFS to GFP_KERNEL 2022-02-25 18:50:12 -05:00
auth_gss.c SUNRPC: Move remaining internal definitions to gss_krb5_internal.h 2023-02-20 09:20:46 -05:00
gss_generic_token.c sunrpc: Remove unneeded null check 2022-01-06 14:00:20 -05:00
gss_krb5_crypto.c SUNRPC: Fix a crash in gss_krb5_checksum() 2023-03-22 16:58:26 -04:00
gss_krb5_internal.h SUNRPC: Add encryption self-tests 2023-02-20 09:20:51 -05:00
gss_krb5_keys.c SUNRPC: Add KUnit tests for rpcsec_krb5.ko 2023-02-20 09:20:46 -05:00
gss_krb5_mech.c SUNRPC: Export get_gss_krb5_enctype() 2023-02-20 09:20:48 -05:00
gss_krb5_seal.c SUNRPC: Enable rpcsec_gss_krb5.ko to be built without CRYPTO_DES 2023-02-20 09:20:41 -05:00
gss_krb5_seqnum.c SUNRPC: Remove ->encrypt and ->decrypt methods from struct gss_krb5_enctype 2023-02-20 09:20:41 -05:00
gss_krb5_test.c SUNRPC: Properly terminate test case arrays 2023-02-27 16:27:51 -05:00
gss_krb5_unseal.c SUNRPC: Enable rpcsec_gss_krb5.ko to be built without CRYPTO_DES 2023-02-20 09:20:41 -05:00
gss_krb5_wrap.c SUNRPC: Rename .encrypt_v2 and .decrypt_v2 methods 2023-02-20 09:20:42 -05:00
gss_mech_switch.c sunrpc: clean up properly in gss_mech_unregister() 2020-05-28 18:15:00 -04:00
gss_rpc_upcall.c SUNRPC: Ensure that the gssproxy client can start in a connected state 2022-05-07 14:31:15 -04:00
gss_rpc_upcall.h SUNRPC: Add SPDX IDs to some net/sunrpc/auth_gss/ files 2019-02-14 09:54:37 -05:00
gss_rpc_xdr.c SUNRPC: Remove XDRBUF_SPARSE_PAGES flag in gss_proxy upcall 2020-12-09 09:38:34 -05:00
gss_rpc_xdr.h SUNRPC: Add SPDX IDs to some net/sunrpc/auth_gss/ files 2019-02-14 09:54:37 -05:00
Makefile SUNRPC: Add KUnit tests for rpcsec_krb5.ko 2023-02-20 09:20:46 -05:00
svcauth_gss.c SUNRPC: Fix occasional warning when destroying gss_krb5_enctypes 2023-02-20 09:20:57 -05:00
trace.c SUNRPC: remove duplicate include 2020-08-19 13:19:42 -04:00