diff options
author | Lukas Wunner <[email protected]> | 2024-09-10 16:30:24 +0200 |
---|---|---|
committer | Herbert Xu <[email protected]> | 2024-10-05 13:22:04 +0800 |
commit | 3b0565c703503f832d6cd7ba805aafa3b330cb9d (patch) | |
tree | 3710dc97b98acfa25d9201a8aff58e767b04cad5 /tools/perf/scripts/python/netdev-times.py | |
parent | 4df86c6ea5c37fe0452638f39a1e4b189da75c54 (diff) |
crypto: ecdsa - Avoid signed integer overflow on signature decoding
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 <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/netdev-times.py')
0 files changed, 0 insertions, 0 deletions