@@ -118,7 +118,7 @@ static int ctr3686_aes_nx_crypt(struct skcipher_request *req)structnx_crypto_ctx*nx_ctx=crypto_skcipher_ctx(tfm);u8iv[16];-memcpy(iv,nx_ctx->priv.ctr.nonce,CTR_RFC3686_IV_SIZE);+memcpy(iv,nx_ctx->priv.ctr.nonce,CTR_RFC3686_NONCE_SIZE);memcpy(iv+CTR_RFC3686_NONCE_SIZE,req->iv,CTR_RFC3686_IV_SIZE);iv[12]=iv[13]=iv[14]=0;iv[15]=1;
Where IV_SIZE is 8 and NONCE_SIZE is 4.
And iv is 16 bytes, so it's not a buffer overflow.
But priv.ctr.nonce is 4 bytes, and at the end of the struct, so it reads
4 bytes past the end of the nx_crypto_ctx, which is not good.
But then immediately overwrites whatever it read with req->iv.
So seems pretty harmless in practice?
cheers
@@ -118,7 +118,7 @@ static int ctr3686_aes_nx_crypt(struct skcipher_request *req)structnx_crypto_ctx*nx_ctx=crypto_skcipher_ctx(tfm);u8iv[16];-memcpy(iv,nx_ctx->priv.ctr.nonce,CTR_RFC3686_IV_SIZE);+memcpy(iv,nx_ctx->priv.ctr.nonce,CTR_RFC3686_NONCE_SIZE);memcpy(iv+CTR_RFC3686_NONCE_SIZE,req->iv,CTR_RFC3686_IV_SIZE);iv[12]=iv[13]=iv[14]=0;iv[15]=1;
Where IV_SIZE is 8 and NONCE_SIZE is 4.
And iv is 16 bytes, so it's not a buffer overflow.
But priv.ctr.nonce is 4 bytes, and at the end of the struct, so it reads
4 bytes past the end of the nx_crypto_ctx, which is not good.
But then immediately overwrites whatever it read with req->iv.
So seems pretty harmless in practice?
Right -- there's no damage done, but future memcpy() FORTIFY work alerts
on this, so I'm going through cleaning all of these up. :)
--
Kees Cook