diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-11-25 18:53:45 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-11-25 18:53:45 -0500 |
| commit | 86b01b5419fd303a3699b2ce6f4b9bfbdaa4ed37 (patch) | |
| tree | 4c148e15bcb4e35220708df1148c024aa9bf8d1b /lib/mpi/mpi-pow.c | |
| parent | cd3caefb4663e3811d37cc2afad3cce642d60061 (diff) | |
| parent | f5527fffff3f002b0a6b376163613b82f69de073 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull keys fixes from James Morris:
"From David:
- Fix mpi_powm()'s handling of a number with a zero exponent
[CVE-2016-8650].
Integrate my and Andrey's patches for mpi_powm() and use
mpi_resize() instead of RESIZE_IF_NEEDED() - the latter adds a
duplicate check into the execution path of a trivial case we
don't normally expect to be taken.
- Fix double free in X.509 error handling"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
mpi: Fix NULL ptr dereference in mpi_powm() [ver #3]
X.509: Fix double free in x509_cert_parse() [ver #3]
Diffstat (limited to 'lib/mpi/mpi-pow.c')
| -rw-r--r-- | lib/mpi/mpi-pow.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c index 5464c8744ea9..e24388a863a7 100644 --- a/lib/mpi/mpi-pow.c +++ b/lib/mpi/mpi-pow.c | |||
| @@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) | |||
| 64 | if (!esize) { | 64 | if (!esize) { |
| 65 | /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 | 65 | /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 |
| 66 | * depending on if MOD equals 1. */ | 66 | * depending on if MOD equals 1. */ |
| 67 | rp[0] = 1; | ||
| 68 | res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1; | 67 | res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1; |
| 68 | if (res->nlimbs) { | ||
| 69 | if (mpi_resize(res, 1) < 0) | ||
| 70 | goto enomem; | ||
| 71 | rp = res->d; | ||
| 72 | rp[0] = 1; | ||
| 73 | } | ||
| 69 | res->sign = 0; | 74 | res->sign = 0; |
| 70 | goto leave; | 75 | goto leave; |
| 71 | } | 76 | } |
