Skip to content

Commit 86b01b5

Browse files
committed
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]
2 parents cd3caef + f5527ff commit 86b01b5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crypto/asymmetric_keys/x509_cert_parser.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
133133
return cert;
134134

135135
error_decode:
136-
kfree(cert->pub->key);
137136
kfree(ctx);
138137
error_no_ctx:
139138
x509_free_certificate(cert);

lib/mpi/mpi-pow.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
6464
if (!esize) {
6565
/* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0
6666
* depending on if MOD equals 1. */
67-
rp[0] = 1;
6867
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+
}
6974
res->sign = 0;
7075
goto leave;
7176
}

0 commit comments

Comments
 (0)