Skip to content

Commit 86b259f

Browse files
committed
tls: rx: device: bound the frag walk
We can't do skb_walk_frags() on the input skbs, because the input skbs is really just a pointer to the tcp read queue. We need to bound the "is decrypted" check by the amount of data in the message. Note that the walk in tls_device_reencrypt() is after a CoW so the skb there is safe to walk. Actually in the current implementation it can't have frags at all, but whatever, maybe one day it will. Reported-by: Tariq Toukan <[email protected]> Fixes: 84c61fe ("tls: rx: do not use the standard strparser") Tested-by: Ran Rozenstein <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9ad3630 commit 86b259f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

net/tls/tls_device.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,11 +984,17 @@ int tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx)
984984
int is_decrypted = skb->decrypted;
985985
int is_encrypted = !is_decrypted;
986986
struct sk_buff *skb_iter;
987+
int left;
987988

989+
left = rxm->full_len - skb->len;
988990
/* Check if all the data is decrypted already */
989-
skb_walk_frags(skb, skb_iter) {
991+
skb_iter = skb_shinfo(skb)->frag_list;
992+
while (skb_iter && left > 0) {
990993
is_decrypted &= skb_iter->decrypted;
991994
is_encrypted &= !skb_iter->decrypted;
995+
996+
left -= skb_iter->len;
997+
skb_iter = skb_iter->next;
992998
}
993999

9941000
trace_tls_device_decrypted(sk, tcp_sk(sk)->copied_seq - rxm->full_len,

0 commit comments

Comments
 (0)