230-eng_devcrypto-close-session-on-cleanup-not-final.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From 5378c582c8d3f1130b17abb2950bfd09cde099c6 Mon Sep 17 00:00:00 2001
  2. From: Eneas U de Queiroz <[email protected]>
  3. Date: Mon, 5 Nov 2018 15:59:44 -0200
  4. Subject: [PATCH 4/7] eng_devcrypto: close session on cleanup, not final
  5. Close the session in digest_cleanup instead of digest_final. A failure
  6. in closing the session does not mean a previous successful digest final
  7. has failed as well.
  8. Signed-off-by: Eneas U de Queiroz <[email protected]>
  9. Reviewed-by: Matthias St. Pierre <[email protected]>
  10. Reviewed-by: Richard Levitte <[email protected]>
  11. (Merged from https://github.com/openssl/openssl/pull/7585)
  12. (cherry picked from commit a67203a19d379a8cc8b369587c60c46eb4e19014)
  13. --- a/crypto/engine/eng_devcrypto.c
  14. +++ b/crypto/engine/eng_devcrypto.c
  15. @@ -461,10 +461,6 @@ static int digest_final(EVP_MD_CTX *ctx,
  16. SYSerr(SYS_F_IOCTL, errno);
  17. return 0;
  18. }
  19. - if (ioctl(cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
  20. - SYSerr(SYS_F_IOCTL, errno);
  21. - return 0;
  22. - }
  23. return 1;
  24. }
  25. @@ -496,6 +492,15 @@ static int digest_copy(EVP_MD_CTX *to, c
  26. static int digest_cleanup(EVP_MD_CTX *ctx)
  27. {
  28. + struct digest_ctx *digest_ctx =
  29. + (struct digest_ctx *)EVP_MD_CTX_md_data(ctx);
  30. +
  31. + if (digest_ctx == NULL)
  32. + return 1;
  33. + if (ioctl(cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
  34. + SYSerr(SYS_F_IOCTL, errno);
  35. + return 0;
  36. + }
  37. return 1;
  38. }