提交 d5262c62 编写于 作者: E Eric Dumazet 提交者: Yang Yingliang

tcp: repair: fix TCP_QUEUE_SEQ implementation

stable inclusion
from linux-4.19.114
commit 58b501cc08ccd688c4dd3d202cbdc4e36aeff79a

--------------------------------

[ Upstream commit 6cd6cbf5 ]

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: ee995283 ("tcp: Initial repair mode")
Fixes: 05255b82 ("tcp: add TCP_ZEROCOPY_RECEIVE support for zerocopy receive")
Signed-off-by: NEric Dumazet <edumazet@google.com>
Reported-by: Nsyzbot <syzkaller@googlegroups.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NLi Aichun <liaichun@huawei.com>
Reviewed-by: Nguodeqing <geffrey.guo@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 0e792e07
...@@ -2870,8 +2870,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level, ...@@ -2870,8 +2870,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
err = -EPERM; err = -EPERM;
else if (tp->repair_queue == TCP_SEND_QUEUE) else if (tp->repair_queue == TCP_SEND_QUEUE)
tp->write_seq = val; tp->write_seq = val;
else if (tp->repair_queue == TCP_RECV_QUEUE) else if (tp->repair_queue == TCP_RECV_QUEUE) {
WRITE_ONCE(tp->rcv_nxt, val); WRITE_ONCE(tp->rcv_nxt, val);
WRITE_ONCE(tp->copied_seq, val);
}
else else
err = -EINVAL; err = -EINVAL;
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册