]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: repair: fix TCP_QUEUE_SEQ implementation
authorEric Dumazet <edumazet@google.com>
Thu, 19 Mar 2020 02:21:02 +0000 (19:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 23 Mar 2020 20:02:01 +0000 (13:02 -0700)
commit68f9f80341ac0a0e257f0a0db5e6de82c11cbaa6
treea92fb9e1ad95e07b71c94a62cc42a322dc7fb167
parent8f56621976a73da5594fdf778e0152e103c7acb6
tcp: repair: fix TCP_QUEUE_SEQ implementation

When application uses TCP_QUEUE_SEQ socket option to
change tp->rcv_next, we must also update tp->copied_seq.

Otherwise, stuff relying on tcp_inq() being precise can
eventually be confused.

For example, tcp_zerocopy_receive() might crash because
it does not expect tcp_recv_skb() to return NULL.

We could add tests in various places to fix the issue,
or simply make sure tcp_inq() wont return a random value,
and leave fast path as it is.

Note that this fixes ioctl(fd, SIOCINQ, &val) at the same
time.

Fixes: a782f9e6e10c ("tcp: Initial repair mode")
Fixes: 339ce0cda26a ("tcp: add TCP_ZEROCOPY_RECEIVE support for zerocopy receive")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c