From nobody Wed Oct 4 19:19:42 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S14JH1Sdxz4vwSg; Wed, 4 Oct 2023 19:19:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S14JH11R5z3f5v; Wed, 4 Oct 2023 19:19:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696447183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nSrFfG6KvvYWBed5NsRv22Ut14/5opTsGKII3onS9AM=; b=VK3vrwLZ5cUALddVC80nAXzxCumUd8wwIFp9V/pUnMX9cnuLS2CV6MmthTRROfeiAAeoxI hRsd3ztNgNiag60BZny8PFEPogYpG7TYqBLIJdDqh3BWexpglnsHeMnmU5ksdLpak4TSMg 0ENl7qrgMf/obv/R5kh4pc+O9dJGwiVUGKF+xZxt5UGbxfXKdy29EI3/7pgLzEayjpXaRS YNc9j5YJa01FBBaYhJQqoWmVqghCAkjnF47qy0gkOhqlXHJQ8qWlyKCwFhsBAK2hecya8w QZ2Wx7wTjMP8EvDb4s6QknvM4WAd5dJBRFdsrXChd/4/cXTSzy9mBK2nvm9CcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696447183; a=rsa-sha256; cv=none; b=XylOG+ScYvKmaBYReTszp4ekcyEZYGJ1z7sT0Xy3wIhiFqMny0dck3jvpCz1l8YF0rKCc4 UZfvhG+24HWpSlLd6xaeEdvgv5cifiXeFRqV0P9CEDUMp8ES1IU5F8FYX6zgH2RLDiGmJY R2Rw+c9reE3/DUOIuLEng11LwLDXkZBh24edmBdsHYsvblQhw0Ue9bfeEJr+EhPEuZEAaB yXfBtD+qqd/Vh0N93C/Rpg8B26re1CxrvVzFidVity01lfiF+Bm1DEoUTkFInd5T3pHhJa qSfNMNR+MijQzo3TwU1GAnHNvwipf38juKvSDqDzITv6fuRTyaNZO32e7QOc0w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696447183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nSrFfG6KvvYWBed5NsRv22Ut14/5opTsGKII3onS9AM=; b=tU3eSOW1uIkeyqFYqFZLtq2ZJQUVC8JZjDJ55xT4L5g11KvwjfacmhxeOiLfSwCmUh+doY Elo+YrjPUtXcYMmHYDe0CL/LIWJ8dPTRJkCzH2oM0uhojYAxlczwERSmJOzXoP+5ukdZW/ ymFWJYLJFoJulJ6njNiTjm1wfWevoDqqPF7Kcft1GakzfRjdDO2horCY4gNYyn71j47MKL 707eNSSc1JuwCw1Fv+yA01VzoXvjvDnNKF97Q83QuE614xkPAVZ96dslyzSwAAcIWog9Dy xEFXMbEzCUG6vczkPDMhd5XHdvTBMjUEy2Jeu5DLGsMYjCAxh+cJMveImKto0w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S14JH04B2zptD; Wed, 4 Oct 2023 19:19:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 394JJgET073152; Wed, 4 Oct 2023 19:19:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 394JJgUE073149; Wed, 4 Oct 2023 19:19:42 GMT (envelope-from git) Date: Wed, 4 Oct 2023 19:19:42 GMT Message-Id: <202310041919.394JJgUE073149@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Randall Stewart Subject: git: 8818f0f1124e - main - TCP: Fix a rack bug that skyzall found which results in a crash. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rrs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8818f0f1124ea3d0e8028f85d667237536eba10c Auto-Submitted: auto-generated The branch main has been updated by rrs: URL: https://cgit.FreeBSD.org/src/commit/?id=8818f0f1124ea3d0e8028f85d667237536eba10c commit 8818f0f1124ea3d0e8028f85d667237536eba10c Author: Randall Stewart AuthorDate: 2023-10-04 19:16:01 +0000 Commit: Randall Stewart CommitDate: 2023-10-04 19:16:01 +0000 TCP: Fix a rack bug that skyzall found which results in a crash. So when we call the fast_rsm retransmit path, we should always move snd_nxt back up to snd_max. In fact during ack-processing if snd_nxt falls behind it should be moved up there as well. Otherwise what can happen is we have an incorrect mark on snd_nxt and incorrectly calculate the offset when we go through the front path (which is what skzyall was able to do) then when we go to clean up the send the offset is all wrong and we crash. Special thanks to Gleb for pointing out the problem and the email that had the reproducer so I could find the issue. Reported-by: syzbot+f5061a372f74f021ec02@syzkaller.appspotmail.com Sponsored by: Netflix Inc --- sys/netinet/tcp_stacks/rack.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index a6e649f78c10..5c16cb9ed23b 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -12342,8 +12342,8 @@ rack_process_ack(struct mbuf *m, struct tcphdr *th, struct socket *so, if (SEQ_GT(tp->snd_una, tp->snd_recover)) tp->snd_recover = tp->snd_una; - if (SEQ_LT(tp->snd_nxt, tp->snd_una)) { - tp->snd_nxt = tp->snd_una; + if (SEQ_LT(tp->snd_nxt, tp->snd_max)) { + tp->snd_nxt = tp->snd_max; } if (under_pacing && (rack->use_fixed_rate == 0) && @@ -16363,8 +16363,8 @@ rack_do_compressed_ack_processing(struct tcpcb *tp, struct socket *so, struct mb /* Send recover and snd_nxt must be dragged along */ if (SEQ_GT(tp->snd_una, tp->snd_recover)) tp->snd_recover = tp->snd_una; - if (SEQ_LT(tp->snd_nxt, tp->snd_una)) - tp->snd_nxt = tp->snd_una; + if (SEQ_LT(tp->snd_nxt, tp->snd_max)) + tp->snd_nxt = tp->snd_max; /* * If the RXT timer is running we want to * stop it, so we can restart a TLP (or new RXT). @@ -19112,6 +19112,8 @@ rack_fast_rsm_output(struct tcpcb *tp, struct tcp_rack *rack, struct rack_sendma lgb->tlb_errno = error; lgb = NULL; } + /* Move snd_nxt to snd_max so we don't have false retransmissions */ + tp->snd_nxt = tp->snd_max; if (error) { goto failed; } else if (rack->rc_hw_nobuf && (ip_sendflag != IP_NO_SND_TAG_RL)) {