]> Git Repo - linux.git/commit - net/ipv4/tcp.c
tcp: clear saved_syn in tcp_disconnect()
authorEric Dumazet <[email protected]>
Sat, 8 Apr 2017 15:07:33 +0000 (08:07 -0700)
committerDavid S. Miller <[email protected]>
Mon, 10 Apr 2017 01:27:28 +0000 (18:27 -0700)
commit17c3060b1701fc69daedb4c90be6325d3d9fca8e
treec150ad0125b753402cc71a88c863b5597f4c6b56
parentdf59577d8c6fecc53e0ea8e98519ee83b4ca5b04
tcp: clear saved_syn in tcp_disconnect()

In the (very unlikely) case a passive socket becomes a listener,
we do not want to duplicate its saved SYN headers.

This would lead to double frees, use after free, and please hackers and
various fuzzers

Tested:
    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
   +0 setsockopt(3, IPPROTO_TCP, TCP_SAVE_SYN, [1], 4) = 0
   +0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0

   +0 bind(3, ..., ...) = 0
   +0 listen(3, 5) = 0

   +0 < S 0:0(0) win 32972 <mss 1460,nop,wscale 7>
   +0 > S. 0:0(0) ack 1 <...>
  +.1 < . 1:1(0) ack 1 win 257
   +0 accept(3, ..., ...) = 4

   +0 connect(4, AF_UNSPEC, ...) = 0
   +0 close(3) = 0
   +0 bind(4, ..., ...) = 0
   +0 listen(4, 5) = 0

   +0 < S 0:0(0) win 32972 <mss 1460,nop,wscale 7>
   +0 > S. 0:0(0) ack 1 <...>
  +.1 < . 1:1(0) ack 1 win 257

Fixes: cd8ae85299d5 ("tcp: provide SYN headers for passive connections")
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/ipv4/tcp.c
This page took 0.075856 seconds and 4 git commands to generate.