linux/drivers/crypto/nx
Sam James 4e67f504ee crypto: nx - fix nx_crypto_ctx_exit argument
nx_crypto_ctx_shash_exit calls nx_crypto_ctx_exit with crypto_shash_ctx(...)
but crypto_shash_ctx gives a nx_crypto_ctx *, not a crypto_tfm *.

Fix the type in nx_crypto_ctx_exit and drop the bogus crypto_tfm_ctx
call.

This fixes the following oops:

  BUG: Unable to handle kernel data access at 0xc0403effffffffc8
  Faulting instruction address: 0xc000000000396cb4
  Oops: Kernel access of bad area, sig: 11 [#15]
  Call Trace:
   nx_crypto_ctx_shash_exit+0x24/0x60
   crypto_shash_exit_tfm+0x28/0x40
   crypto_destroy_tfm+0x98/0x140
   crypto_exit_ahash_using_shash+0x20/0x40
   crypto_destroy_tfm+0x98/0x140
   hash_release+0x1c/0x30
   alg_sock_destruct+0x38/0x60
   __sk_destruct+0x48/0x2b0
   af_alg_release+0x58/0xb0
   __sock_release+0x68/0x150
   sock_close+0x20/0x40
   __fput+0x110/0x3a0
   sys_close+0x48/0xa0
   system_call_exception+0x140/0x2d0
   system_call_common+0xf4/0x258

.. which came from hardlink(1) opportunistically using AF_ALG.

The same problem exists with nx_crypto_ctx_skcipher_exit getting a context
it wasn't expecting, but apparently nobody hit that for years.

Cc: Eric Biggers <ebiggers@kernel.org>
Cc: stable@vger.kernel.org
Fixes: bfd9efddf9 ("crypto: nx - convert AES-ECB to skcipher API")
Fixes: 9420e628e7 ("crypto: nx - Use API partial block handling")
Acked-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Reported-by: Calvin Buckley <calvin@cmpct.info>
Tested-by: Calvin Buckley <calvin@cmpct.info>
Suggested-by: Brad Spengler <brad.spengler@opensrcsec.com>
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2026-06-05 19:36:35 +08:00
..
Kconfig crypto/nx: Register and unregister VAS interface on PowerVM 2021-06-20 21:58:58 +10:00
Makefile crypto: nx - fix build warnings when DEBUG_FS is not enabled 2023-05-24 18:12:33 +08:00
nx_csbcpb.h crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx_debugfs.c crypto: nx - Repair some kernel-doc problems 2021-03-26 20:02:36 +11:00
nx-842.c crypto: nx - fix context leak in nx842_crypto_free_ctx 2026-03-22 11:17:59 +09:00
nx-842.h crypto: nx - Fix packed layout in struct nx842_crypto_header 2026-03-27 18:52:43 +09:00
nx-aes-cbc.c crypto: nx - Add missing header inclusions 2025-04-16 15:16:21 +08:00
nx-aes-ccm.c crypto: nx - use the new scatterwalk functions 2025-03-02 15:19:43 +08:00
nx-aes-ctr.c crypto: nx - Add missing header inclusions 2025-04-16 15:16:21 +08:00
nx-aes-ecb.c crypto: nx - Add missing header inclusions 2025-04-16 15:16:21 +08:00
nx-aes-gcm.c crypto: nx - use the new scatterwalk functions 2025-03-02 15:19:43 +08:00
nx-aes-xcbc.c crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00
nx-common-powernv.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nx-common-pseries.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nx-sha256.c crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00
nx-sha512.c crypto: nx - Use API partial block handling 2025-04-23 15:52:47 +08:00
nx.c crypto: nx - fix nx_crypto_ctx_exit argument 2026-06-05 19:36:35 +08:00
nx.h crypto: nx - fix nx_crypto_ctx_exit argument 2026-06-05 19:36:35 +08:00