1
0
Fork 0
remarkable-linux/lib/mpi
Eric Biggers 443d26a6f7 lib/mpi: call cond_resched() from mpi_powm() loop
commit 1d9ddde12e upstream.

On a non-preemptible kernel, if KEYCTL_DH_COMPUTE is called with the
largest permitted inputs (16384 bits), the kernel spends 10+ seconds
doing modular exponentiation in mpi_powm() without rescheduling.  If all
threads do it, it locks up the system.  Moreover, it can cause
rcu_sched-stall warnings.

Notwithstanding the insanity of doing this calculation in kernel mode
rather than in userspace, fix it by calling cond_resched() as each bit
from the exponent is processed.  It's still noninterruptible, but at
least it's preemptible now.

Do the cond_resched() once per bit rather than once per MPI limb because
each limb might still easily take 100+ milliseconds on slow CPUs.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-30 08:39:01 +00:00
..
Makefile MPILIB: Reinstate mpi_cmp[_ui]() and export for RSA signature verification 2012-10-08 13:50:15 +10:30
generic_mpih-add1.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-lshift.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-mul1.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-mul2.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-mul3.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-rshift.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
generic_mpih-sub1.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
longlong.h lib/mpi: avoid assembler warning 2016-02-28 03:26:34 +08:00
mpi-bit.c MPILIB: Provide count_leading/trailing_zeros() based on arch functions 2012-10-08 13:50:11 +10:30
mpi-cmp.c MPILIB: Fix comparison of negative MPIs 2015-01-14 16:10:12 +00:00
mpi-inline.h lib/mpi: use "static inline" instead of "extern inline" 2016-02-28 03:26:34 +08:00
mpi-internal.h lib/mpi: use "static inline" instead of "extern inline" 2016-02-28 03:26:34 +08:00
mpi-pow.c lib/mpi: call cond_resched() from mpi_powm() loop 2017-11-30 08:39:01 +00:00
mpicoder.c lib/mpi: kunmap after finishing accessing buffer 2017-09-07 08:35:40 +02:00
mpih-cmp.c crypto: GnuPG based MPI lib - source files (part 1) 2011-11-09 11:45:22 +02:00
mpih-div.c Remove unused code from MPI library 2012-05-26 11:51:03 +10:00
mpih-mul.c Remove unused code from MPI library 2012-05-26 11:51:03 +10:00
mpiutil.c MPILIB: add mpi_read_buf() and mpi_get_size() helpers 2015-06-16 14:35:06 +08:00