diff mbox series

crypto: authencesn - Fix incorrect setauthsize function

Message ID 20231013095523.184497-1-ingyujang25@unist.ac.kr
State New
Headers show
Series crypto: authencesn - Fix incorrect setauthsize function | expand

Commit Message

Ingyu Jang Oct. 13, 2023, 9:55 a.m. UTC
Fixes a mismatch between 'setauthsize' documentation and
actual behavior of 'crypto_authenc_esn_setauthsize()' function

As per the documentation in  'aead.h' for the '@setauthsize' attribute:

@setauthsize: Set authentication size for the AEAD transformation. This
function is used to specify the consumer requested size of the
authentication tag to be either generated by the transformation
during encryption or the size of the authentication tag to be
supplied during the decryption operation. This function is also
responsible for checking the authentication tag size for
validity.

However, the implementation does not align with this description.
The function only checked the validity of the input authsize without setting it.
Consequently, 'authsize' is used without being initialized,
resulting in an uninitialized memory read issue.

Signed-off-by: Ingyu Jang <ingyujang25@unist.ac.kr>
---
 crypto/authencesn.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/crypto/authencesn.c b/crypto/authencesn.c
index 91424e791d5c..c1346d5b7950 100644
--- a/crypto/authencesn.c
+++ b/crypto/authencesn.c
@@ -52,6 +52,8 @@  static int crypto_authenc_esn_setauthsize(struct crypto_aead *authenc_esn,
 	if (authsize > 0 && authsize < 4)
 		return -EINVAL;
 
+	authenc_esn->authsize = authsize;
+
 	return 0;
 }