Skip to content

Commit 676a2b8

Browse files
vinaychelsiogregkh
authored andcommitted
chelsio/chtls: fix tls record info to user
[ Upstream commit 4f3391c ] chtls_pt_recvmsg() receives a skb with tls header and subsequent skb with data, need to finalize the data copy whenever next skb with tls header is available. but here current tls header is overwritten by next available tls header, ends up corrupting user buffer data. fixing it by finalizing current record whenever next skb contains tls header. v1->v2: - Improved commit message. Fixes: 17a7d24 ("crypto: chtls - generic handling of data and hdr") Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com> Link: https://lore.kernel.org/r/20201022190556.21308-1-vinay.yadav@chelsio.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a368a6e commit 676a2b8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/crypto/chelsio/chtls/chtls_io.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,7 @@ static int chtls_pt_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
15851585
tp->urg_data = 0;
15861586

15871587
if ((avail + offset) >= skb->len) {
1588+
struct sk_buff *next_skb;
15881589
if (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_TLS_HDR) {
15891590
tp->copied_seq += skb->len;
15901591
hws->rcvpld = skb->hdr_len;
@@ -1595,8 +1596,10 @@ static int chtls_pt_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
15951596
chtls_free_skb(sk, skb);
15961597
buffers_freed++;
15971598
hws->copied_seq = 0;
1598-
if (copied >= target &&
1599-
!skb_peek(&sk->sk_receive_queue))
1599+
next_skb = skb_peek(&sk->sk_receive_queue);
1600+
if (copied >= target && !next_skb)
1601+
break;
1602+
if (ULP_SKB_CB(next_skb)->flags & ULPCB_FLAG_TLS_HDR)
16001603
break;
16011604
}
16021605
} while (len > 0);

0 commit comments

Comments
 (0)