enc_perf merge causes crypto library to leak like a sieve....

Ezra Peisach epeisach at MIT.EDU
Mon Oct 19 20:21:52 EDT 2009


I have tracked down one leak.... in krb5int_yarrow_cipher_init the code 
looks like:

  krb5_k_free_key(NULL, ctx->key);
  ctx->key = NULL;
.
.
.
ret = krb5_k_create_key(NULL, &keyblock, &ctx->key);


krb5_k_create_key allocates ctx->key and copies the keyblock contents 
but krb5_k_free_key only frees the keyblock contents - but not ctx->key.

So - either the fix in ycipher.c is to free ctx->key before setting it 
to NULL - or krb5_k_free_key needs to be modified....

I leave it to Greg or someone better familiar with the intention on how 
to proceed - but I think krb5_k_free_key needs the modification....

Ezra


Ezra Peisach wrote:
> Running valgrind on the various crypto_tests show memory leaks... For 
> the trunk pre-merge there aren't any leaks (at least for the limited 
> tests I have done)...
>
> Looks like a big leak in the yarrow code to start with.... 170 blocks 
> below - within yarrow - seems excessive...
>
> For instance  t_encrypt:
>
>
> ==24759==
> ==24759== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1)
> ==24759== malloc/free: in use at exit: 4,524 bytes in 239 blocks.
> ==24759== malloc/free: 1,434 allocs, 1,195 frees, 50,710 bytes allocated.
> ==24759== For counts of detected errors, rerun with: -v
> ==24759== searching for pointers to 239 not-freed blocks.
> ==24759== checked 116,668 bytes.
> ==24759==
> ==24759== 300 bytes in 60 blocks are definitely lost in loss record 2 of 3
> ==24759==    at 0x4006F3D: malloc (vg_replace_malloc.c:207)
> ==24759==    by 0x40CB77B: krb5_derive_key (derive.c:55)
> ==24759==    by 0x40CAF5F: krb5_dk_encrypt (dk_encrypt.c:93)
> ==24759==    by 0x40E0466: krb5_k_encrypt (encrypt.c:54)
> ==24759==    by 0x40E054E: krb5_c_encrypt (encrypt.c:69)
> ==24759==    by 0x8048E78: main (t_encrypt.c:134)
> ==24759==
> ==24759==
> ==24759== 4,224 (4,080 direct, 144 indirect) bytes in 170 blocks are 
> definitely lost in loss record 3 of 3
> ==24759==    at 0x4006F3D: malloc (vg_replace_malloc.c:207)
> ==24759==    by 0x40E0A8E: krb5_k_create_key (key.c:45)
> ==24759==    by 0x40D070B: krb5int_yarrow_cipher_init (ycipher.c:61)
> ==24759==    by 0x40D04B2: krb5int_yarrow_init (yarrow.c:198)
> ==24759==    by 0x40E28F9: krb5int_prng_init (prng.c:69)
> ==24759==    by 0x40DFE00: cryptoint_initialize_library__aux 
> (crypto_libinit.c:16)
> ==24759==    by 0x40DFE94: krb5int_crypto_init (crypto_libinit.c:21)
> ==24759==    by 0x40E2631: krb5_c_random_add_entropy (prng.c:89)
> ==24759==    by 0x40E28BB: krb5_c_random_seed (prng.c:104)
> ==24759==    by 0x8048C36: main (t_encrypt.c:97)
> ==24759==
> ==24759== LEAK SUMMARY:
> ==24759==    definitely lost: 4,380 bytes in 230 blocks.
> ==24759==    indirectly lost: 144 bytes in 9 blocks.
> ==24759==      possibly lost: 0 bytes in 0 blocks.
> ==24759==    still reachable: 0 bytes in 0 blocks.
> ==24759==         suppressed: 0 bytes in 0 blocks.
> [epeisach at beast crypto_tests]$
>
>
> Ezra
>
> _______________________________________________
> krbdev mailing list             krbdev at mit.edu
> https://mailman.mit.edu/mailman/listinfo/krbdev
>   




More information about the krbdev mailing list