diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-05 13:58:06 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-05 13:58:06 -0400 |
| commit | f8ce1faf55955de62e0a12e330c6d9a526071f65 (patch) | |
| tree | a3b0ddd3f37e40d3ed0fd2cd433a2723403c8b97 /crypto | |
| parent | 24d0c2542b38963ae4d5171ecc0a2c1326c656bc (diff) | |
| parent | a53a11f35762ff1d5e268adedf2ab9ce313f871d (diff) | |
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull mudule updates from Rusty Russell:
"We get rid of the general module prefix confusion with a binary config
option, fix a remove/insert race which Never Happens, and (my
favorite) handle the case when we have too many modules for a single
commandline. Seriously, the kernel is full, please go away!"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
modpost: fix unwanted VMLINUX_SYMBOL_STR expansion
X.509: Support parse long form of length octets in Authority Key Identifier
module: don't unlink the module until we've removed all exposure.
kernel: kallsyms: memory override issue, need check destination buffer length
MODSIGN: do not send garbage to stderr when enabling modules signature
modpost: handle huge numbers of modules.
modpost: add -T option to read module names from file/stdin.
modpost: minor cleanup.
genksyms: pass symbol-prefix instead of arch
module: fix symbol versioning with symbol prefixes
CONFIG_SYMBOL_PREFIX: cleanup.
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/asymmetric_keys/x509_cert_parser.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c index 7fabc4c01993..facbf26bc6bb 100644 --- a/crypto/asymmetric_keys/x509_cert_parser.c +++ b/crypto/asymmetric_keys/x509_cert_parser.c | |||
| @@ -373,6 +373,9 @@ int rsa_extract_mpi(void *context, size_t hdrlen, | |||
| 373 | return 0; | 373 | return 0; |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | /* The keyIdentifier in AuthorityKeyIdentifier SEQUENCE is tag(CONT,PRIM,0) */ | ||
| 377 | #define SEQ_TAG_KEYID (ASN1_CONT << 6) | ||
| 378 | |||
| 376 | /* | 379 | /* |
| 377 | * Process certificate extensions that are used to qualify the certificate. | 380 | * Process certificate extensions that are used to qualify the certificate. |
| 378 | */ | 381 | */ |
| @@ -407,21 +410,57 @@ int x509_process_extension(void *context, size_t hdrlen, | |||
| 407 | } | 410 | } |
| 408 | 411 | ||
| 409 | if (ctx->last_oid == OID_authorityKeyIdentifier) { | 412 | if (ctx->last_oid == OID_authorityKeyIdentifier) { |
| 413 | size_t key_len; | ||
| 414 | |||
| 410 | /* Get hold of the CA key fingerprint */ | 415 | /* Get hold of the CA key fingerprint */ |
| 411 | if (vlen < 5) | 416 | if (vlen < 5) |
| 412 | return -EBADMSG; | 417 | return -EBADMSG; |
| 413 | if (v[0] != (ASN1_SEQ | (ASN1_CONS << 5)) || | 418 | |
| 414 | v[1] != vlen - 2 || | 419 | /* Authority Key Identifier must be a Constructed SEQUENCE */ |
| 415 | v[2] != (ASN1_CONT << 6) || | 420 | if (v[0] != (ASN1_SEQ | (ASN1_CONS << 5))) |
| 416 | v[3] != vlen - 4) | ||
| 417 | return -EBADMSG; | 421 | return -EBADMSG; |
| 418 | v += 4; | ||
| 419 | vlen -= 4; | ||
| 420 | 422 | ||
| 421 | f = kmalloc(vlen * 2 + 1, GFP_KERNEL); | 423 | /* Authority Key Identifier is not indefinite length */ |
| 424 | if (unlikely(vlen == ASN1_INDEFINITE_LENGTH)) | ||
| 425 | return -EBADMSG; | ||
| 426 | |||
| 427 | if (vlen < ASN1_INDEFINITE_LENGTH) { | ||
| 428 | /* Short Form length */ | ||
| 429 | if (v[1] != vlen - 2 || | ||
| 430 | v[2] != SEQ_TAG_KEYID || | ||
| 431 | v[3] > vlen - 4) | ||
| 432 | return -EBADMSG; | ||
| 433 | |||
| 434 | key_len = v[3]; | ||
| 435 | v += 4; | ||
| 436 | } else { | ||
| 437 | /* Long Form length */ | ||
| 438 | size_t seq_len = 0; | ||
| 439 | size_t sub = v[1] - ASN1_INDEFINITE_LENGTH; | ||
| 440 | |||
| 441 | if (sub > 2) | ||
| 442 | return -EBADMSG; | ||
| 443 | |||
| 444 | /* calculate the length from subsequent octets */ | ||
| 445 | v += 2; | ||
| 446 | for (i = 0; i < sub; i++) { | ||
| 447 | seq_len <<= 8; | ||
| 448 | seq_len |= v[i]; | ||
| 449 | } | ||
| 450 | |||
| 451 | if (seq_len != vlen - 2 - sub || | ||
| 452 | v[sub] != SEQ_TAG_KEYID || | ||
| 453 | v[sub + 1] > vlen - 4 - sub) | ||
| 454 | return -EBADMSG; | ||
| 455 | |||
| 456 | key_len = v[sub + 1]; | ||
| 457 | v += (sub + 2); | ||
| 458 | } | ||
| 459 | |||
| 460 | f = kmalloc(key_len * 2 + 1, GFP_KERNEL); | ||
| 422 | if (!f) | 461 | if (!f) |
| 423 | return -ENOMEM; | 462 | return -ENOMEM; |
| 424 | for (i = 0; i < vlen; i++) | 463 | for (i = 0; i < key_len; i++) |
| 425 | sprintf(f + i * 2, "%02x", v[i]); | 464 | sprintf(f + i * 2, "%02x", v[i]); |
| 426 | pr_debug("authority %s\n", f); | 465 | pr_debug("authority %s\n", f); |
| 427 | ctx->cert->authority = f; | 466 | ctx->cert->authority = f; |
