msan.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. --- a/crypto/ec/ecp_nistz256.c
  2. +++ b/crypto/ec/ecp_nistz256.c
  3. @@ -24,6 +24,7 @@
  4. #include "crypto/bn.h"
  5. #include "ec_local.h"
  6. #include "internal/refcount.h"
  7. +#include "sanitizers.h"
  8. #if BN_BITS2 != 64
  9. # define TOBN(hi,lo) lo,hi
  10. @@ -1150,6 +1151,8 @@ __owur static int ecp_nistz256_points_mul(const EC_GROUP *group,
  11. ecp_nistz256_point_add(&p.p, &p.p, out);
  12. }
  13. + __msan_unpoison(&p.p, sizeof(p.p));
  14. +
  15. /* Not constant-time, but we're only operating on the public output. */
  16. if (!bn_set_words(r->X, p.p.X, P256_LIMBS) ||
  17. !bn_set_words(r->Y, p.p.Y, P256_LIMBS) ||
  18. @@ -1196,6 +1199,7 @@ __owur static int ecp_nistz256_get_affine(const EC_GROUP *group,
  19. if (x != NULL) {
  20. ecp_nistz256_from_mont(x_ret, x_aff);
  21. + __msan_unpoison(x_ret, sizeof(x_ret));
  22. if (!bn_set_words(x, x_ret, P256_LIMBS))
  23. return 0;
  24. }
  25. @@ -1204,6 +1208,7 @@ __owur static int ecp_nistz256_get_affine(const EC_GROUP *group,
  26. ecp_nistz256_mul_mont(z_inv3, z_inv3, z_inv2);
  27. ecp_nistz256_mul_mont(y_aff, z_inv3, point_y);
  28. ecp_nistz256_from_mont(y_ret, y_aff);
  29. + __msan_unpoison(y_ret, sizeof(y_ret));
  30. if (!bn_set_words(y, y_ret, P256_LIMBS))
  31. return 0;
  32. }
  33. @@ -1446,6 +1451,7 @@ static int ecp_nistz256_inv_mod_ord(const EC_GROUP *group, BIGNUM *r,
  34. }
  35. #endif
  36. ecp_nistz256_ord_mul_mont(out, out, one);
  37. + __msan_unpoison(out, sizeof(out));
  38. /*
  39. * Can't fail, but check return code to be consistent anyway.
  40. --- a/crypto/evp/e_aes.c
  41. +++ b/crypto/evp/e_aes.c
  42. @@ -18,6 +18,7 @@
  43. #include "modes_local.h"
  44. #include <openssl/rand.h>
  45. #include "evp_local.h"
  46. +#include "sanitizers.h"
  47. typedef struct {
  48. union {
  49. @@ -304,6 +305,7 @@ static int aesni_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
  50. aesni_cbc_encrypt(in, out, len, &EVP_C_DATA(EVP_AES_KEY,ctx)->ks.ks,
  51. EVP_CIPHER_CTX_iv_noconst(ctx),
  52. EVP_CIPHER_CTX_encrypting(ctx));
  53. + __msan_unpoison(out, len);
  54. return 1;
  55. }
  56. @@ -318,6 +320,7 @@ static int aesni_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
  57. aesni_ecb_encrypt(in, out, len, &EVP_C_DATA(EVP_AES_KEY,ctx)->ks.ks,
  58. EVP_CIPHER_CTX_encrypting(ctx));
  59. + __msan_unpoison(out, len);
  60. return 1;
  61. }
  62. @@ -3293,6 +3296,7 @@ static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
  63. return -1;
  64. }
  65. }
  66. + __msan_unpoison(out, len);
  67. return len;
  68. } else {
  69. if (!ctx->encrypt) {