diff options
Diffstat (limited to 'net/tls/tls_sw.c')
-rw-r--r-- | net/tls/tls_sw.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 52fbe727d7c1..b9c6ecfbcfea 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c | |||
@@ -125,6 +125,9 @@ static int alloc_encrypted_sg(struct sock *sk, int len) | |||
125 | &ctx->sg_encrypted_num_elem, | 125 | &ctx->sg_encrypted_num_elem, |
126 | &ctx->sg_encrypted_size, 0); | 126 | &ctx->sg_encrypted_size, 0); |
127 | 127 | ||
128 | if (rc == -ENOSPC) | ||
129 | ctx->sg_encrypted_num_elem = ARRAY_SIZE(ctx->sg_encrypted_data); | ||
130 | |||
128 | return rc; | 131 | return rc; |
129 | } | 132 | } |
130 | 133 | ||
@@ -138,6 +141,9 @@ static int alloc_plaintext_sg(struct sock *sk, int len) | |||
138 | &ctx->sg_plaintext_num_elem, &ctx->sg_plaintext_size, | 141 | &ctx->sg_plaintext_num_elem, &ctx->sg_plaintext_size, |
139 | tls_ctx->pending_open_record_frags); | 142 | tls_ctx->pending_open_record_frags); |
140 | 143 | ||
144 | if (rc == -ENOSPC) | ||
145 | ctx->sg_plaintext_num_elem = ARRAY_SIZE(ctx->sg_plaintext_data); | ||
146 | |||
141 | return rc; | 147 | return rc; |
142 | } | 148 | } |
143 | 149 | ||
@@ -925,7 +931,15 @@ int tls_sw_recvmsg(struct sock *sk, | |||
925 | if (control != TLS_RECORD_TYPE_DATA) | 931 | if (control != TLS_RECORD_TYPE_DATA) |
926 | goto recv_end; | 932 | goto recv_end; |
927 | } | 933 | } |
934 | } else { | ||
935 | /* MSG_PEEK right now cannot look beyond current skb | ||
936 | * from strparser, meaning we cannot advance skb here | ||
937 | * and thus unpause strparser since we'd loose original | ||
938 | * one. | ||
939 | */ | ||
940 | break; | ||
928 | } | 941 | } |
942 | |||
929 | /* If we have a new message from strparser, continue now. */ | 943 | /* If we have a new message from strparser, continue now. */ |
930 | if (copied >= target && !ctx->recv_pkt) | 944 | if (copied >= target && !ctx->recv_pkt) |
931 | break; | 945 | break; |
@@ -1049,8 +1063,8 @@ static int tls_read_size(struct strparser *strp, struct sk_buff *skb) | |||
1049 | goto read_failure; | 1063 | goto read_failure; |
1050 | } | 1064 | } |
1051 | 1065 | ||
1052 | if (header[1] != TLS_VERSION_MINOR(tls_ctx->crypto_recv.version) || | 1066 | if (header[1] != TLS_VERSION_MINOR(tls_ctx->crypto_recv.info.version) || |
1053 | header[2] != TLS_VERSION_MAJOR(tls_ctx->crypto_recv.version)) { | 1067 | header[2] != TLS_VERSION_MAJOR(tls_ctx->crypto_recv.info.version)) { |
1054 | ret = -EINVAL; | 1068 | ret = -EINVAL; |
1055 | goto read_failure; | 1069 | goto read_failure; |
1056 | } | 1070 | } |
@@ -1130,7 +1144,6 @@ void tls_sw_free_resources_rx(struct sock *sk) | |||
1130 | 1144 | ||
1131 | int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) | 1145 | int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) |
1132 | { | 1146 | { |
1133 | char keyval[TLS_CIPHER_AES_GCM_128_KEY_SIZE]; | ||
1134 | struct tls_crypto_info *crypto_info; | 1147 | struct tls_crypto_info *crypto_info; |
1135 | struct tls12_crypto_info_aes_gcm_128 *gcm_128_info; | 1148 | struct tls12_crypto_info_aes_gcm_128 *gcm_128_info; |
1136 | struct tls_sw_context_tx *sw_ctx_tx = NULL; | 1149 | struct tls_sw_context_tx *sw_ctx_tx = NULL; |
@@ -1175,12 +1188,12 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) | |||
1175 | 1188 | ||
1176 | if (tx) { | 1189 | if (tx) { |
1177 | crypto_init_wait(&sw_ctx_tx->async_wait); | 1190 | crypto_init_wait(&sw_ctx_tx->async_wait); |
1178 | crypto_info = &ctx->crypto_send; | 1191 | crypto_info = &ctx->crypto_send.info; |
1179 | cctx = &ctx->tx; | 1192 | cctx = &ctx->tx; |
1180 | aead = &sw_ctx_tx->aead_send; | 1193 | aead = &sw_ctx_tx->aead_send; |
1181 | } else { | 1194 | } else { |
1182 | crypto_init_wait(&sw_ctx_rx->async_wait); | 1195 | crypto_init_wait(&sw_ctx_rx->async_wait); |
1183 | crypto_info = &ctx->crypto_recv; | 1196 | crypto_info = &ctx->crypto_recv.info; |
1184 | cctx = &ctx->rx; | 1197 | cctx = &ctx->rx; |
1185 | aead = &sw_ctx_rx->aead_recv; | 1198 | aead = &sw_ctx_rx->aead_recv; |
1186 | } | 1199 | } |
@@ -1259,9 +1272,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) | |||
1259 | 1272 | ||
1260 | ctx->push_pending_record = tls_sw_push_pending_record; | 1273 | ctx->push_pending_record = tls_sw_push_pending_record; |
1261 | 1274 | ||
1262 | memcpy(keyval, gcm_128_info->key, TLS_CIPHER_AES_GCM_128_KEY_SIZE); | 1275 | rc = crypto_aead_setkey(*aead, gcm_128_info->key, |
1263 | |||
1264 | rc = crypto_aead_setkey(*aead, keyval, | ||
1265 | TLS_CIPHER_AES_GCM_128_KEY_SIZE); | 1276 | TLS_CIPHER_AES_GCM_128_KEY_SIZE); |
1266 | if (rc) | 1277 | if (rc) |
1267 | goto free_aead; | 1278 | goto free_aead; |