aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-22 23:15:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-22 23:15:48 -0400
commit897473fc040fd69e9a4a6da2ac62a4724a4a8619 (patch)
tree04055fca343e99164548cb38271bec0fae7c2673
parent3aa536d9aafc2806dd3439114e25b253086312a9 (diff)
parentacddc72015e5bc8f640b02d38b36afd7841c9c14 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull key handling fixes from James Morris: "Quoting David Howells: Here are three miscellaneous fixes: (1) Fix a panic in some debugging code in PKCS#7. This can only happen by explicitly inserting a #define DEBUG into the code. (2) Fix the calculation of the digest length in the PE file parser. This causes a failure where there should be a success. (3) Fix the case where an X.509 cert can be added as an asymmetric key to a trusted keyring with no trust restriction if no AKID is supplied. Bugs (1) and (2) aren't particularly problematic, but (3) allows a security check to be bypassed. Happily, this is a recent regression and never made it into a released kernel" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: KEYS: Fix for erroneous trust of incorrectly signed X.509 certs pefile: Fix the failure of calculation for digest PKCS#7: Fix panic when referring to the empty AKID when DEBUG defined
-rw-r--r--crypto/asymmetric_keys/mscode_parser.c7
-rw-r--r--crypto/asymmetric_keys/pkcs7_verify.c2
-rw-r--r--crypto/asymmetric_keys/restrict.c2
3 files changed, 8 insertions, 3 deletions
diff --git a/crypto/asymmetric_keys/mscode_parser.c b/crypto/asymmetric_keys/mscode_parser.c
index 6a76d5c70ef6..9492e1c22d38 100644
--- a/crypto/asymmetric_keys/mscode_parser.c
+++ b/crypto/asymmetric_keys/mscode_parser.c
@@ -124,5 +124,10 @@ int mscode_note_digest(void *context, size_t hdrlen,
124 struct pefile_context *ctx = context; 124 struct pefile_context *ctx = context;
125 125
126 ctx->digest = kmemdup(value, vlen, GFP_KERNEL); 126 ctx->digest = kmemdup(value, vlen, GFP_KERNEL);
127 return ctx->digest ? 0 : -ENOMEM; 127 if (!ctx->digest)
128 return -ENOMEM;
129
130 ctx->digest_len = vlen;
131
132 return 0;
128} 133}
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
index 44b746e9df1b..2ffd69769466 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -227,7 +227,7 @@ static int pkcs7_verify_sig_chain(struct pkcs7_message *pkcs7,
227 if (asymmetric_key_id_same(p->id, auth)) 227 if (asymmetric_key_id_same(p->id, auth))
228 goto found_issuer_check_skid; 228 goto found_issuer_check_skid;
229 } 229 }
230 } else { 230 } else if (sig->auth_ids[1]) {
231 auth = sig->auth_ids[1]; 231 auth = sig->auth_ids[1];
232 pr_debug("- want %*phN\n", auth->len, auth->data); 232 pr_debug("- want %*phN\n", auth->len, auth->data);
233 for (p = pkcs7->certs; p; p = p->next) { 233 for (p = pkcs7->certs; p; p = p->next) {
diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c
index ac4bddf669de..19d1afb9890f 100644
--- a/crypto/asymmetric_keys/restrict.c
+++ b/crypto/asymmetric_keys/restrict.c
@@ -87,7 +87,7 @@ int restrict_link_by_signature(struct key *trust_keyring,
87 87
88 sig = payload->data[asym_auth]; 88 sig = payload->data[asym_auth];
89 if (!sig->auth_ids[0] && !sig->auth_ids[1]) 89 if (!sig->auth_ids[0] && !sig->auth_ids[1])
90 return 0; 90 return -ENOKEY;
91 91
92 if (ca_keyid && !asymmetric_key_id_partial(sig->auth_ids[1], ca_keyid)) 92 if (ca_keyid && !asymmetric_key_id_partial(sig->auth_ids[1], ca_keyid))
93 return -EPERM; 93 return -EPERM;