Dmitry Safonov
9aedd10fe3
crypto: ahash - Set using_shash for cloned ahash wrapper over shash
The cloned child of ahash that uses shash under the hood should use
shash helpers (like crypto_shash_setkey()).
The following panic may be observed on TCP-AO selftests:
> ==================================================================
> BUG: KASAN: wild-memory-access in crypto_mod_get+0x1b/0x60
> Write of size 4 at addr 5d5be0ff5c415e14 by task connect_ipv4/1397
>
> CPU: 0 PID: 1397 Comm: connect_ipv4 Tainted: G W 6.6.0+ #47
> Call Trace:
> <TASK>
> dump_stack_lvl+0x46/0x70
> kasan_report+0xc3/0xf0
> kasan_check_range+0xec/0x190
> crypto_mod_get+0x1b/0x60
> crypto_spawn_alg+0x53/0x140
> crypto_spawn_tfm2+0x13/0x60
> hmac_init_tfm+0x25/0x60
> crypto_ahash_setkey+0x8b/0x100
> tcp_ao_add_cmd+0xe7a/0x1120
> do_tcp_setsockopt+0x5ed/0x12a0
> do_sock_setsockopt+0x82/0x100
> __sys_setsockopt+0xe9/0x160
> __x64_sys_setsockopt+0x60/0x70
> do_syscall_64+0x3c/0xe0
> entry_SYSCALL_64_after_hwframe+0x46/0x4e
> ==================================================================
> general protection fault, probably for non-canonical address 0x5d5be0ff5c415e14: 0000 [#1] PREEMPT SMP KASAN
> CPU: 0 PID: 1397 Comm: connect_ipv4 Tainted: G B W 6.6.0+ #47
> Call Trace:
> <TASK>
> ? die_addr+0x3c/0xa0
> ? exc_general_protection+0x144/0x210
> ? asm_exc_general_protection+0x22/0x30
> ? add_taint+0x26/0x90
> ? crypto_mod_get+0x20/0x60
> ? crypto_mod_get+0x1b/0x60
> ? ahash_def_finup_done1+0x58/0x80
> crypto_spawn_alg+0x53/0x140
> crypto_spawn_tfm2+0x13/0x60
> hmac_init_tfm+0x25/0x60
> crypto_ahash_setkey+0x8b/0x100
> tcp_ao_add_cmd+0xe7a/0x1120
> do_tcp_setsockopt+0x5ed/0x12a0
> do_sock_setsockopt+0x82/0x100
> __sys_setsockopt+0xe9/0x160
> __x64_sys_setsockopt+0x60/0x70
> do_syscall_64+0x3c/0xe0
> entry_SYSCALL_64_after_hwframe+0x46/0x4e
> </TASK>
> RIP: 0010:crypto_mod_get+0x20/0x60
Make sure that the child/clone has using_shash set when parent is
an shash user.
Fixes: 2f1f34c1bf ("crypto: ahash - optimize performance when wrapping shash")
Cc: David Ahern <dsahern@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Dmitry Safonov <0x7f454c46@gmail.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Francesco Ruggeri <fruggeri05@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Salam Noureddine <noureddine@arista.com>
Cc: netdev@vger.kernel.org
Cc: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2023-11-07 16:44:36 +08:00
..
2023-10-27 18:04:30 +08:00
2023-03-24 18:22:28 +08:00
2023-05-02 18:22:24 +08:00
2023-11-01 12:58:42 +08:00
2023-09-20 13:15:29 +08:00
2023-05-24 18:12:33 +08:00
2023-05-24 18:12:33 +08:00
2023-05-24 18:12:33 +08:00
2022-12-02 18:12:40 +08:00
2022-12-02 18:12:40 +08:00
2023-08-29 11:23:29 -07:00
2023-11-07 16:44:36 +08:00
2023-06-27 17:59:52 +08:00
2023-08-11 19:19:27 +08:00
2022-11-25 17:39:18 +08:00
2023-06-24 15:50:13 -07:00
2023-07-08 22:48:42 +10:00
2023-06-24 15:50:13 -07:00
2023-06-24 15:50:13 -07:00
2022-12-02 18:12:40 +08:00
2023-09-20 13:15:29 +08:00
2023-10-13 18:27:26 +08:00
2023-01-06 17:15:47 +08:00
2023-10-27 18:04:29 +08:00
2023-10-27 18:04:29 +08:00
2022-12-02 18:12:40 +08:00
2022-12-02 18:12:40 +08:00
2022-12-02 18:12:40 +08:00
2022-12-02 18:12:40 +08:00
2022-12-02 18:12:40 +08:00
2023-09-20 13:15:29 +08:00
2023-10-27 18:04:29 +08:00
2022-03-03 10:49:20 +12:00
2023-10-27 18:04:29 +08:00
2023-06-23 16:15:36 +08:00
2023-10-27 18:04:24 +08:00
2023-03-14 17:06:42 +08:00
2022-03-07 12:48:35 -07:00
2023-10-13 18:27:26 +08:00
2023-10-01 16:28:15 +08:00
2023-03-14 17:06:42 +08:00
2023-10-13 18:27:27 +08:00
2023-10-13 18:27:27 +08:00
2022-09-24 16:14:43 +08:00
2023-10-12 21:59:32 +08:00
2022-12-02 18:12:40 +08:00
2022-03-03 10:47:50 +12:00
2023-02-13 18:35:14 +08:00
2023-10-27 18:04:25 +08:00
2023-09-20 13:15:29 +08:00
2023-02-14 13:39:33 +08:00
2022-09-24 16:14:43 +08:00
2022-09-24 16:14:43 +08:00
2021-10-29 21:04:03 +08:00
2022-04-29 13:44:58 +08:00
2023-10-13 18:27:26 +08:00
2022-12-02 18:12:40 +08:00
2023-03-17 11:16:44 +08:00
2023-10-27 18:04:29 +08:00
2023-10-27 18:04:30 +08:00
2023-10-27 18:04:30 +08:00
2023-10-27 18:04:25 +08:00
2023-10-27 18:04:24 +08:00
2023-06-27 15:40:24 +08:00
2023-10-13 18:31:07 +08:00
2023-05-12 18:48:01 +08:00
2023-10-27 18:04:25 +08:00
2023-10-13 18:31:07 +08:00
2023-11-07 16:44:35 +08:00
2022-11-25 17:39:18 +08:00
2022-12-02 18:12:40 +08:00
2023-05-02 18:22:24 +08:00
2023-10-13 18:27:27 +08:00
2023-10-20 13:39:26 +08:00
2023-09-20 13:15:29 +08:00
2023-09-15 18:29:45 +08:00
2022-06-10 16:40:17 +08:00
2023-02-14 13:39:33 +08:00
2023-05-02 18:22:24 +08:00
2023-10-27 18:04:30 +08:00
2023-06-23 16:15:36 +08:00
2023-10-27 18:04:28 +08:00
2023-10-27 18:04:28 +08:00
2023-05-02 18:22:24 +08:00
2022-12-02 18:12:40 +08:00
2023-02-13 18:35:14 +08:00
2022-12-02 18:12:40 +08:00
2021-12-31 18:10:54 +11:00
2023-10-27 18:04:30 +08:00
2023-07-20 22:15:12 +12:00
2023-10-20 13:39:26 +08:00
2023-10-20 13:39:26 +08:00
2023-06-23 16:15:37 +08:00
2022-01-28 16:51:11 +11:00
2022-04-08 16:11:48 +08:00
2022-12-02 18:12:40 +08:00
2022-04-08 16:12:46 +08:00
2023-04-14 18:59:34 +08:00
2023-01-20 18:29:31 +08:00
2022-12-02 18:12:40 +08:00
2023-11-01 12:58:42 +08:00
2023-10-20 13:39:26 +08:00
2022-12-02 18:12:40 +08:00
2022-12-02 18:12:40 +08:00
2023-10-27 18:04:24 +08:00
2022-12-30 22:56:27 +08:00
2023-10-27 18:04:25 +08:00
2022-06-10 16:40:16 +08:00
2023-10-20 13:39:25 +08:00
2021-11-08 16:55:21 -08:00