Lukas Wunner
c82bb825f9
crypto: ecdsa - Avoid signed integer overflow on signature decoding
...
[ Upstream commit 3b0565c703 ]
When extracting a signature component r or s from an ASN.1-encoded
integer, ecdsa_get_signature_rs() subtracts the expected length
"bufsize" from the ASN.1 length "vlen" (both of unsigned type size_t)
and stores the result in "diff" (of signed type ssize_t).
This results in a signed integer overflow if vlen > SSIZE_MAX + bufsize.
The kernel is compiled with -fno-strict-overflow, which implies -fwrapv,
meaning signed integer overflow is not undefined behavior. And the
function does check for overflow:
if (-diff >= bufsize)
return -EINVAL;
So the code is fine in principle but not very obvious. In the future it
might trigger a false-positive with CONFIG_UBSAN_SIGNED_WRAP=y.
Avoid by comparing the two unsigned variables directly and erroring out
if "vlen" is too large.
Signed-off-by: Lukas Wunner <lukas@wunner.de >
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com >
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com >
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2024-12-14 20:03:36 +01:00
..
2024-09-20 19:49:49 +03:00
2023-03-24 18:22:28 +08:00
2024-04-02 10:49:38 +08:00
2023-11-01 12:58:42 +08:00
2024-04-26 17:26:09 +08:00
2024-09-13 18:26:52 +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
2024-10-02 17:23:23 -04:00
2022-12-02 18:12:40 +08:00
2024-05-31 17:34:56 +08:00
2024-04-02 10:49:38 +08:00
2024-04-02 10:49:38 +08:00
2024-10-10 17:03:35 +08:00
2024-09-06 14:50:46 +08:00
2023-06-24 15:50:13 -07:00
2024-05-31 17:34:56 +08:00
2023-06-24 15:50:13 -07:00
2024-05-31 17:34:56 +08:00
2022-12-02 18:12:40 +08:00
2024-09-06 14:50:46 +08:00
2023-12-08 11:59:46 +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
2024-10-02 17:23:23 -04:00
2022-12-02 18:12:40 +08:00
2024-10-02 17:23:23 -04:00
2024-04-24 16:01:10 -07:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-05-31 17:34:56 +08:00
2024-02-02 18:08:12 +08:00
2023-10-27 18:04:29 +08:00
2024-08-17 13:55:49 +08:00
2024-10-02 17:23:23 -04:00
2024-04-26 17:26:09 +08:00
2023-10-27 18:04:24 +08:00
2024-04-02 10:49:38 +08:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2023-10-13 18:27:26 +08:00
2023-10-01 16:28:15 +08:00
2024-04-02 10:49:38 +08:00
2023-10-13 18:27:27 +08:00
2023-10-13 18:27:27 +08:00
2024-05-31 17:34:56 +08:00
2024-06-28 11:35:47 +10:00
2022-12-02 18:12:40 +08:00
2024-08-17 13:55:50 +08:00
2023-11-17 19:16:29 +08:00
2023-12-08 11:59:46 +08:00
2024-04-12 15:07:52 +08:00
2024-10-02 17:23:23 -04:00
2024-04-26 17:26:09 +08:00
2024-12-14 20:03:36 +01:00
2024-04-12 15:07:52 +08:00
2024-04-02 10:49:38 +08:00
2023-10-13 18:27:26 +08:00
2022-12-02 18:12:40 +08:00
2024-04-05 15:46:33 +08:00
2023-10-27 18:04:29 +08:00
2023-10-27 18:04:30 +08:00
2024-04-02 10:49:38 +08:00
2023-10-27 18:04:25 +08:00
2023-10-27 18:04:24 +08:00
2024-08-24 21:39:15 +08:00
2024-04-05 15:46:33 +08:00
2023-05-12 18:48:01 +08:00
2024-08-30 18:22:30 +08:00
2023-10-13 18:31:07 +08:00
2024-08-24 21:36:07 +08:00
2022-11-25 17:39:18 +08:00
2022-12-02 18:12:40 +08:00
2024-04-02 10:49:38 +08:00
2023-10-13 18:27:27 +08:00
2024-04-02 10:49:38 +08:00
2024-06-07 19:46:39 +08:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-01-26 16:39:32 +08:00
2024-12-05 14:01:18 +01:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2023-02-14 13:39:33 +08:00
2024-04-02 10:49:38 +08:00
2023-10-27 18:04:30 +08:00
2024-08-17 13:55:50 +08:00
2023-10-27 18:04:28 +08:00
2023-10-27 18:04:28 +08:00
2024-04-02 10:49:38 +08:00
2022-12-02 18:12:40 +08:00
2023-02-13 18:35:14 +08:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-04-02 10:49:38 +08:00
2024-04-02 10:49:38 +08:00
2024-08-24 21:39:15 +08:00
2024-04-02 10:49:38 +08:00
2024-04-02 10:49:38 +08:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2024-06-28 11:35:46 +10:00
2023-01-20 18:29:31 +08:00
2022-12-02 18:12:40 +08:00
2024-10-10 17:03:35 +08:00
2024-06-07 19:46:39 +08:00
2022-12-02 18:12:40 +08:00
2024-10-02 17:23:23 -04:00
2024-10-02 17:23:23 -04:00
2022-12-30 22:56:27 +08:00
2023-10-27 18:04:25 +08:00
2024-08-02 20:53:25 +08:00
2023-10-20 13:39:25 +08:00
2024-10-02 17:23:23 -04:00