Commit 46a16959 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net/tls: fix lowat calculation if some data came from previous record

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: 692d7b5d ("tls: Fix recvmsg() to be able to peek across multiple records")
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarDirk van der Merwe <dirk.vandermerwe@netronome.com>
Tested-by: default avatarDavid Beckett <david.beckett@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 66a04abf
...@@ -1712,13 +1712,12 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1712,13 +1712,12 @@ int tls_sw_recvmsg(struct sock *sk,
copied = err; copied = err;
} }
len = len - copied; if (len <= copied)
if (len) { goto recv_end;
target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
len = len - copied;
timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
} else {
goto recv_end;
}
do { do {
bool retain_skb = false; bool retain_skb = false;
...@@ -1853,7 +1852,7 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1853,7 +1852,7 @@ int tls_sw_recvmsg(struct sock *sk,
} }
/* If we have a new message from strparser, continue now. */ /* If we have a new message from strparser, continue now. */
if (decrypted >= target && !ctx->recv_pkt) if (decrypted + copied >= target && !ctx->recv_pkt)
break; break;
} while (len); } while (len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment