Skip to contentSkip to conversation

KEYS: Fix signature input size for KEYCTL_PKEY_VERIFY

PATCH In review Stefan Berger 2 participants 5 messages Nov 13

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KEYS: Fix signature input size for KEYCTL_PKEY_VERIFY

Revert the changes made for signature verification in cb481e59ea6c back to the old behavior where effectively the params->in2_len was set to the length of the user provided buffer uparams.in2_len (out_len is an alias for in2_len due to the union). We cannot use the max_sig_size in the case of signature verification since this is neither the true size of the input buffer nor would it pass tests of size indicators found in the ASN.1 in the buffer comparing against the input buffer size.

Fixes cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Cc Jarkko Sakkinen <[email protected]>
Cc Florian Bauckholt <[email protected]>
---
 security/keys/keyctl_pkey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/keyctl_pkey.c +1 -1
index 15b6bf6399b5..794fa3d01911 100644
@@ -160,7 +160,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
 		    uparams.in2_len > info.max_sig_size)
 			return -EINVAL;
 
-		params->out_len = info.max_sig_size;
+		params->in2_len = uparams.in2_len;
 		break;
 	default:
 		return -EOPNOTSUPP;
Signature · 1 line
2.56.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Stefan Berger

Revert the changes made for signature verification in cb481e59ea6c back to the old behavior where effectively the params->in2_len was set to the length of the user provided buffer uparams.in2_len (out_len is an alias for in2_len due to the union). We cannot use the max_sig_size in the case of signature verification since this is neither the true size of the input buffer nor would it pass tests of size indicators found in the ASN.1 in the buffer comparing against the input buffer size.

Fixes cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Cc Jarkko Sakkinen <[email protected]>
Cc Florian Bauckholt <[email protected]>
---
 security/keys/keyctl_pkey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/keyctl_pkey.c +1 -1
index 15b6bf6399b5..794fa3d01911 100644
@@ -160,7 +160,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
 		    uparams.in2_len > info.max_sig_size)
 			return -EINVAL;
 
-		params->out_len = info.max_sig_size;
+		params->in2_len = uparams.in2_len;
 		break;
 	default:
 		return -EOPNOTSUPP;
Signature · 1 line
2.56.0

Thanks.

Br, Jarkko

maintainer
#2 lore raw
Quoted 25 lines · Jarkko Sakkinen
Quoted 24 lines · Stefan Berger

Revert the changes made for signature verification in cb481e59ea6c back to the old behavior where effectively the params->in2_len was set to the length of the user provided buffer uparams.in2_len (out_len is an alias for in2_len due to the union). We cannot use the max_sig_size in the case of signature verification since this is neither the true size of the input buffer nor would it pass tests of size indicators found in the ASN.1 in the buffer comparing against the input buffer size.

Fixes cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Cc Jarkko Sakkinen <[email protected]>
Cc Florian Bauckholt <[email protected]>
---
 security/keys/keyctl_pkey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/keyctl_pkey.c +0 -0
index 15b6bf6399b5..794fa3d01911 100644
@@ -160,7 +160,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
 		    uparams.in2_len > info.max_sig_size)
 			return -EINVAL;
 
Quoted 11 lines
Quoted 8 lines
security/keys/keyctl_pkey.c +1 -1
-		params->out_len = info.max_sig_size;
+		params->in2_len = uparams.in2_len;
 		break;
 	default:
 		return -EOPNOTSUPP;
Signature · 1 line
2.56.0

Did we have reported-by and closes tags for this?

Br, Jarkko

#3 lore raw
Quoted 38 lines · Jarkko Sakkinen
Quoted 25 lines · Jarkko Sakkinen
Quoted 24 lines · Stefan Berger

Revert the changes made for signature verification in cb481e59ea6c back to the old behavior where effectively the params->in2_len was set to the length of the user provided buffer uparams.in2_len (out_len is an alias for in2_len due to the union). We cannot use the max_sig_size in the case of signature verification since this is neither the true size of the input buffer nor would it pass tests of size indicators found in the ASN.1 in the buffer comparing against the input buffer size.

Fixes cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Cc Jarkko Sakkinen <[email protected]>
Cc Florian Bauckholt <[email protected]>
---
  security/keys/keyctl_pkey.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/keyctl_pkey.c +0 -0
index 15b6bf6399b5..794fa3d01911 100644
@@ -160,7 +160,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
  		    uparams.in2_len > info.max_sig_size)
  			return -EINVAL;
 
Quoted 11 lines
Quoted 8 lines
security/keys/keyctl_pkey.c +1 -1
-		params->out_len = info.max_sig_size;
+		params->in2_len = uparams.in2_len;
  		break;
  	default:
  		return -EOPNOTSUPP;
Signature · 1 line
2.56.0
Quoted 1 line

Did we have reported-by and closes tags for this?

Let me add this here for v2:

Once Florian added his Tested-by: to v1 should I then add this?

Quoted 2 lines

Br, Jarkko

maintainer
#4 lore raw
Quoted 42 lines · Stefan Berger
Quoted 37 lines · Jarkko Sakkinen
Quoted 27 lines · Jarkko Sakkinen
Quoted 26 lines · Stefan Berger

Revert the changes made for signature verification in cb481e59ea6c back to the old behavior where effectively the params->in2_len was set to the length of the user provided buffer uparams.in2_len (out_len is an alias for in2_len due to the union). We cannot use the max_sig_size in the case of signature verification since this is neither the true size of the input buffer nor would it pass tests of size indicators found in the ASN.1 in the buffer comparing against the input buffer size.

Fixes cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Cc Jarkko Sakkinen <[email protected]>
Cc Florian Bauckholt <[email protected]>
---
  security/keys/keyctl_pkey.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/keyctl_pkey.c +1 -1
index 15b6bf6399b5..794fa3d01911 100644
@@ -160,7 +160,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
  		    uparams.in2_len > info.max_sig_size)
  			return -EINVAL;
-		params->out_len = info.max_sig_size;
+		params->in2_len = uparams.in2_len;
  		break;
Quoted 8 lines
Quoted 5 lines
security/keys/keyctl_pkey.c +0 -0
  	default:
  		return -EOPNOTSUPP;
Signature · 1 line
2.56.0
Quoted 1 line

Did we have reported-by and closes tags for this?

Quoted 8 lines

Let me add this here for v2:

Once Florian added his Tested-by: to v1 should I then add this?

Nah, I don't care about Sashiko tags, no need to add em.

Go ahead and add Florian's tested-by.

Br, Jarkko