[PATCH 1/3] tls: retrun the correct IV in getsockopt

Subsystems: networking [general], networking [tls], the rest

STALE3126d

6 messages, 2 authors, 2018-02-14 · open the first message on its own page

[PATCH 1/3] tls: retrun the correct IV in getsockopt

From: Boris Pismenny <hidden>
Date: 2018-02-14 08:46:18

Current code returns four bytes of salt followed by four bytes of IV.
This patch returns all eight bytes of IV.

fixes: 3c4d7559159b ("tls: kernel TLS support")
Signed-off-by: Boris Pismenny <redacted>
---
 net/tls/tls_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index b0d5fce..a6c3702 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -308,7 +308,8 @@ static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval,
 			goto out;
 		}
 		lock_sock(sk);
-		memcpy(crypto_info_aes_gcm_128->iv, ctx->iv,
+		memcpy(crypto_info_aes_gcm_128->iv,
+		       ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
 		       TLS_CIPHER_AES_GCM_128_IV_SIZE);
 		release_sock(sk);
 		if (copy_to_user(optval,
-- 
1.8.3.1

[PATCH 2/3] tls: reset the crypto info if copy_from_user fails

From: Boris Pismenny <hidden>
Date: 2018-02-14 08:46:18

copy_from_user could copy some partial information, as a result
TLS_CRYPTO_INFO_READY(crypto_info) could be true while crypto_info is
using uninitialzed data.

This patch resets crypto_info when copy_from_user fails.

fixes: 3c4d7559159b ("tls: kernel TLS support")
Signed-off-by: Boris Pismenny <redacted>
---
 net/tls/tls_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index a6c3702..c105f86 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -376,7 +376,7 @@ static int do_tls_setsockopt_tx(struct sock *sk, char __user *optval,
 	rc = copy_from_user(crypto_info, optval, sizeof(*crypto_info));
 	if (rc) {
 		rc = -EFAULT;
-		goto out;
+		goto err_crypto_info;
 	}
 
 	/* check version */
-- 
1.8.3.1

[PATCH 3/3] tls: getsockopt return record sequence number

From: Boris Pismenny <hidden>
Date: 2018-02-14 08:46:18

Return the TLS record sequence number in getsockopt.

Signed-off-by: Boris Pismenny <redacted>
---
 net/tls/tls_main.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index c105f86..e9b4b53 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -311,6 +311,8 @@ static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval,
 		memcpy(crypto_info_aes_gcm_128->iv,
 		       ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
 		       TLS_CIPHER_AES_GCM_128_IV_SIZE);
+		memcpy(crypto_info_aes_gcm_128->rec_seq, ctx->rec_seq,
+		       TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
 		release_sock(sk);
 		if (copy_to_user(optval,
 				 crypto_info_aes_gcm_128,
-- 
1.8.3.1

Re: [PATCH 1/3] tls: retrun the correct IV in getsockopt

From: David Miller <davem@davemloft.net>
Date: 2018-02-14 20:07:02

From: Boris Pismenny <redacted>
Date: Wed, 14 Feb 2018 10:46:06 +0200
Current code returns four bytes of salt followed by four bytes of IV.
This patch returns all eight bytes of IV.

fixes: 3c4d7559159b ("tls: kernel TLS support")
Signed-off-by: Boris Pismenny <redacted>
Applied.

Re: [PATCH 2/3] tls: reset the crypto info if copy_from_user fails

From: David Miller <davem@davemloft.net>
Date: 2018-02-14 20:07:07

From: Boris Pismenny <redacted>
Date: Wed, 14 Feb 2018 10:46:07 +0200
copy_from_user could copy some partial information, as a result
TLS_CRYPTO_INFO_READY(crypto_info) could be true while crypto_info is
using uninitialzed data.

This patch resets crypto_info when copy_from_user fails.

fixes: 3c4d7559159b ("tls: kernel TLS support")
Signed-off-by: Boris Pismenny <redacted>
Applied.

Re: [PATCH 3/3] tls: getsockopt return record sequence number

From: David Miller <davem@davemloft.net>
Date: 2018-02-14 20:07:13

From: Boris Pismenny <redacted>
Date: Wed, 14 Feb 2018 10:46:08 +0200
Return the TLS record sequence number in getsockopt.

Signed-off-by: Boris Pismenny <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help