Go to file
Hongbo Li 7e433ef602 lib/mpi: use kcalloc in mpi_resize
[ Upstream commit b6f756726e4dfe75be1883f6a0202dcecdc801ab ]

We should set the additional space to 0 in mpi_resize().
So use kcalloc() instead of kmalloc_array().

In lib/mpi/ec.c:
/****************
 * Resize the array of A to NLIMBS. the additional space is cleared
 * (set to 0) [done by m_realloc()]
 */
int mpi_resize(MPI a, unsigned nlimbs)

Like the comment of kernel's mpi_resize() said, the additional space
need to be set to 0, but when a->d is not NULL, it does not set.

The kernel's mpi lib is from libgcrypt, the mpi resize in libgcrypt
is _gcry_mpi_resize() which set the additional space to 0.

This bug may cause mpi api which use mpi_resize() get wrong result
under the condition of using the additional space without initiation.
If this condition is not met, the bug would not be triggered.
Currently in kernel, rsa, sm2 and dh use mpi lib, and they works well,
so the bug is not triggered in these cases.

add_points_edwards() use the additional space directly, so it will
get a wrong result.

Fixes: cdec9cb516 ("crypto: GnuPG based MPI lib - source files (part 1)")
Signed-off-by: Hongbo Li <herberthbli@tencent.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-05 19:10:07 +02:00
arch m68k: Fix invalid RMW_INSNS on CPUs that lack CAS 2024-07-05 19:10:07 +02:00
block block: return ELEVATOR_DISCARD_MERGE if possible 2024-07-05 19:10:07 +02:00
certs certs: add 'x509_revocation_list' to gitignore 2021-07-20 16:05:35 +02:00
crypto init: add dsm gpl source 2024-07-05 18:00:04 +02:00
Documentation dt-bindings: sifive-l2-cache: Fix 'select' matching 2024-07-05 19:00:49 +02:00
drivers irqchip/loongson-pch-pic: Improve edge triggered interrupt support 2024-07-05 19:10:07 +02:00
fs udf_get_extendedattr() had no boundary checks. 2024-07-05 19:09:51 +02:00
include block: return ELEVATOR_DISCARD_MERGE if possible 2024-07-05 19:10:07 +02:00
init init: add dsm gpl source 2024-07-05 18:00:04 +02:00
ipc ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry 2021-05-26 12:06:54 +02:00
kernel genirq/timings: Fix error return code in irq_timings_test_irqs() 2024-07-05 19:10:07 +02:00
lib lib/mpi: use kcalloc in mpi_resize 2024-07-05 19:10:07 +02:00
LICENSES LICENSES/deprecated: add Zlib license text 2020-09-16 14:33:49 +02:00
mm mm/page_alloc: speed up the iteration of max_order 2024-07-05 19:06:11 +02:00
net netfilter: nftables: clone set element expression template 2024-07-05 19:07:11 +02:00
samples samples/bpf: Fix the error return code of xdp_redirect's main() 2021-07-14 16:56:23 +02:00
scripts scripts/tracing: fix the bug that can't parse raw_trace_func 2024-07-05 18:52:27 +02:00
security bpf: Add lockdown check for probe_write_user helper 2024-07-05 18:53:10 +02:00
sound ALSA: usb-audio: Add registration quirk for JBL Quantum 800 2024-07-05 19:07:18 +02:00
SynoBuildConf init: add dsm gpl source 2024-07-05 18:00:04 +02:00
synology init: add dsm gpl source 2024-07-05 18:00:04 +02:00
tools perf annotate: Fix jump parsing for C++ code. 2024-07-05 19:01:01 +02:00
usr Merge branch 'work.fdpic' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-08-07 13:29:39 -07:00
virt KVM: Do not leak memory for duplicate debugfs directories 2024-07-05 18:52:31 +02:00
.clang-format init: add dsm gpl source 2024-07-05 18:00:04 +02:00
.cocciconfig scripts: add Linux .cocciconfig for coccinelle 2016-07-22 12:13:39 +02:00
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl 2019-05-16 10:53:40 -07:00
.gitattributes .gitattributes: use 'dts' diff driver for dts files 2019-12-04 19:44:11 -08:00
.gitignore kbuild: generate Module.symvers only when vmlinux exists 2021-05-19 10:12:59 +02:00
.mailmap mailmap: add two more addresses of Uwe Kleine-König 2020-12-06 10:19:07 -08:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS MAINTAINERS: Move Jason Cooper to CREDITS 2020-11-30 10:20:34 +01:00
Kbuild kbuild: rename hostprogs-y/always to hostprogs/always-y 2020-02-04 01:53:07 +09:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS init: add dsm gpl source 2024-07-05 18:00:04 +02:00
Makefile init: add dsm gpl source 2024-07-05 18:00:04 +02:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.