summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorVakul Garg <vakul.garg@nxp.com>2018-09-06 21:41:40 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-26 08:39:20 +0200
commitb800b7ef44b5312281fd0ef02758d49a26acce57 (patch)
treea3fe893e738e8333f0db7272caab7752d62a8e4d /net
parentc73238573deaa6dce0b42a72eaa783e364a42dd2 (diff)
downloadlinux-stable-b800b7ef44b5312281fd0ef02758d49a26acce57.tar.gz
linux-stable-b800b7ef44b5312281fd0ef02758d49a26acce57.tar.bz2
linux-stable-b800b7ef44b5312281fd0ef02758d49a26acce57.zip
net/tls: Set count of SG entries if sk_alloc_sg returns -ENOSPC
[ Upstream commit 52ea992cfac357b73180d5c051dca43bc8d20c2a ] tls_sw_sendmsg() allocates plaintext and encrypted SG entries using function sk_alloc_sg(). In case the number of SG entries hit MAX_SKB_FRAGS, sk_alloc_sg() returns -ENOSPC and sets the variable for current SG index to '0'. This leads to calling of function tls_push_record() with 'sg_encrypted_num_elem = 0' and later causes kernel crash. To fix this, set the number of SG elements to the number of elements in plaintext/encrypted SG arrays in case sk_alloc_sg() returns -ENOSPC. Fixes: 3c4d7559159b ("tls: kernel TLS support") Signed-off-by: Vakul Garg <vakul.garg@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/tls/tls_sw.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 1f3d9789af30..db0712b8ddf1 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -149,6 +149,9 @@ static int alloc_encrypted_sg(struct sock *sk, int len)
&ctx->sg_encrypted_num_elem,
&ctx->sg_encrypted_size, 0);
+ if (rc == -ENOSPC)
+ ctx->sg_encrypted_num_elem = ARRAY_SIZE(ctx->sg_encrypted_data);
+
return rc;
}
@@ -162,6 +165,9 @@ static int alloc_plaintext_sg(struct sock *sk, int len)
&ctx->sg_plaintext_num_elem, &ctx->sg_plaintext_size,
tls_ctx->pending_open_record_frags);
+ if (rc == -ENOSPC)
+ ctx->sg_plaintext_num_elem = ARRAY_SIZE(ctx->sg_plaintext_data);
+
return rc;
}