summaryrefslogtreecommitdiff
path: root/include/linux/rwsem.h
diff options
context:
space:
mode:
authorLukas Wunner <lukas@wunner.de>2024-09-10 17:30:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-01-09 15:31:41 +0300
commit4b6beff3c073b3bd0dcb4cb16822408fc51e5df1 (patch)
tree7e7dff53e55f9ba227931317abba3d87a3d93944 /include/linux/rwsem.h
parentec64889179410e67d1b2aa7b047cafaa2d0c3f43 (diff)
downloadlinux-4b6beff3c073b3bd0dcb4cb16822408fc51e5df1.tar.xz
crypto: ecdsa - Avoid signed integer overflow on signature decoding
[ Upstream commit 3b0565c703503f832d6cd7ba805aafa3b330cb9d ] 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>
Diffstat (limited to 'include/linux/rwsem.h')
0 files changed, 0 insertions, 0 deletions