Skip to content

Commit 4fd44a9

Browse files
fllindendavem330
authored andcommitted
tcp: verify the checksum of the first data segment in a new connection
commit 079096f ("tcp/dccp: install syn_recv requests into ehash table") introduced an optimization for the handling of child sockets created for a new TCP connection. But this optimization passes any data associated with the last ACK of the connection handshake up the stack without verifying its checksum, because it calls tcp_child_process(), which in turn calls tcp_rcv_state_process() directly. These lower-level processing functions do not do any checksum verification. Insert a tcp_checksum_complete call in the TCP_NEW_SYN_RECEIVE path to fix this. Fixes: 079096f ("tcp/dccp: install syn_recv requests into ehash table") Signed-off-by: Frank van der Linden <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Tested-by: Balbir Singh <[email protected]> Reviewed-by: Balbir Singh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bdf767c commit 4fd44a9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

net/ipv4/tcp_ipv4.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
17301730
reqsk_put(req);
17311731
goto discard_it;
17321732
}
1733+
if (tcp_checksum_complete(skb)) {
1734+
reqsk_put(req);
1735+
goto csum_error;
1736+
}
17331737
if (unlikely(sk->sk_state != TCP_LISTEN)) {
17341738
inet_csk_reqsk_queue_drop_and_put(sk, req);
17351739
goto lookup;

net/ipv6/tcp_ipv6.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,10 @@ static int tcp_v6_rcv(struct sk_buff *skb)
14791479
reqsk_put(req);
14801480
goto discard_it;
14811481
}
1482+
if (tcp_checksum_complete(skb)) {
1483+
reqsk_put(req);
1484+
goto csum_error;
1485+
}
14821486
if (unlikely(sk->sk_state != TCP_LISTEN)) {
14831487
inet_csk_reqsk_queue_drop_and_put(sk, req);
14841488
goto lookup;

0 commit comments

Comments
 (0)