aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-05-24 17:34:30 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-04 05:59:44 (GMT)
commit2b4435b877d80fc0d048009c3cf289cb55797f4f (patch)
tree9c93dc84fe34d1ced8d847f35c1ff82e349a8ee1
parent7b16eb9190b2eb4d2a063260f9951c859bc850ad (diff)
downloadkernel_replicant_linux-2b4435b877d80fc0d048009c3cf289cb55797f4f.zip
kernel_replicant_linux-2b4435b877d80fc0d048009c3cf289cb55797f4f.tar.gz
kernel_replicant_linux-2b4435b877d80fc0d048009c3cf289cb55797f4f.tar.bz2
net/tls: fix lowat calculation if some data came from previous record
[ Upstream commit 46a1695960d0600d58da7af33c65f24f3d839674 ] If some of the data came from the previous record, i.e. from the rx_list it had already been decrypted, so it's not counted towards the "decrypted" variable, but the "copied" variable. Take that into account when checking lowat. When calculating lowat target we need to pass the original len. E.g. if lowat is at 80, len is 100 and we had 30 bytes on rx_list target would currently be incorrectly calculated as 70, even though we only need 50 more bytes to make up the 80. Fixes: 692d7b5d1f91 ("tls: Fix recvmsg() to be able to peek across multiple records") Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com> Tested-by: David Beckett <david.beckett@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/tls/tls_sw.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 29d6af4..467c685 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1685,13 +1685,12 @@ int tls_sw_recvmsg(struct sock *sk,
copied = err;
}
- len = len - copied;
- if (len) {
- target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
- timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
- } else {
+ if (len <= copied)
goto recv_end;
- }
+
+ target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
+ len = len - copied;
+ timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
do {
bool retain_skb = false;
@@ -1826,7 +1825,7 @@ pick_next_record:
}
/* If we have a new message from strparser, continue now. */
- if (decrypted >= target && !ctx->recv_pkt)
+ if (decrypted + copied >= target && !ctx->recv_pkt)
break;
} while (len);