Skip to content

Commit f2feaef

Browse files
cpaaschdavem330
authored andcommitted
tcp: Don't access TCP_SKB_CB before initializing it
Since commit eeea10b ("tcp: add tcp_v4_fill_cb()/tcp_v4_restore_cb()"), tcp_vX_fill_cb is only called after tcp_filter(). That means, TCP_SKB_CB(skb)->end_seq still points to the IP-part of the cb. We thus should not mock with it, as this can trigger bugs (thanks syzkaller): [ 12.349396] ================================================================== [ 12.350188] BUG: KASAN: slab-out-of-bounds in ip6_datagram_recv_specific_ctl+0x19b3/0x1a20 [ 12.351035] Read of size 1 at addr ffff88006adbc208 by task test_ip6_datagr/1799 Setting end_seq is actually no more necessary in tcp_filter as it gets initialized later on in tcp_vX_fill_cb. Cc: Eric Dumazet <[email protected]> Fixes: eeea10b ("tcp: add tcp_v4_fill_cb()/tcp_v4_restore_cb()") Signed-off-by: Christoph Paasch <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0b31d98 commit f2feaef

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

net/ipv4/tcp_ipv4.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,15 +1734,8 @@ EXPORT_SYMBOL(tcp_add_backlog);
17341734
int tcp_filter(struct sock *sk, struct sk_buff *skb)
17351735
{
17361736
struct tcphdr *th = (struct tcphdr *)skb->data;
1737-
unsigned int eaten = skb->len;
1738-
int err;
17391737

1740-
err = sk_filter_trim_cap(sk, skb, th->doff * 4);
1741-
if (!err) {
1742-
eaten -= skb->len;
1743-
TCP_SKB_CB(skb)->end_seq -= eaten;
1744-
}
1745-
return err;
1738+
return sk_filter_trim_cap(sk, skb, th->doff * 4);
17461739
}
17471740
EXPORT_SYMBOL(tcp_filter);
17481741

0 commit comments

Comments
 (0)