git: af04a618ed08 - stable/13 - sctp: make sure new locking requirements are satisfied.

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Wed, 23 Feb 2022 00:20:30 UTC
The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=af04a618ed089c016f5a76794b0cebd0e9a732ae

commit af04a618ed089c016f5a76794b0cebd0e9a732ae
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2022-02-20 14:31:53 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2022-02-23 00:19:01 +0000

    sctp: make sure new locking requirements are satisfied.
    
    Reported by:    syzbot+cd3c1dd64861b8c200bd@syzkaller.appspotmail.com
    
    (cherry picked from commit e255f0c9fbd2e1b27f57459d3af18fa19166969d)
---
 sys/netinet/sctp_output.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index 86cf2ed75e90..43804b161cda 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -13321,6 +13321,10 @@ skip_preblock:
 					sp->processing = 0;
 				}
 				SCTP_TCB_SEND_UNLOCK(stcb);
+				if (!hold_tcblock) {
+					SCTP_TCB_LOCK(stcb);
+					hold_tcblock = true;
+				}
 				goto skip_out_eof;
 			}
 			/* What about the INIT, send it maybe */
@@ -13513,8 +13517,8 @@ skip_preblock:
 	if (error != 0) {
 		goto out;
 	}
-dataless_eof:
 
+dataless_eof:
 	KASSERT(stcb != NULL, ("stcb is NULL"));
 	KASSERT(hold_tcblock, ("hold_tcblock is false"));
 	SCTP_TCB_LOCK_ASSERT(stcb);
@@ -13602,6 +13606,7 @@ dataless_eof:
 			}
 		}
 	}
+
 skip_out_eof:
 	KASSERT(stcb != NULL, ("stcb is NULL"));
 	KASSERT(hold_tcblock, ("hold_tcblock is false"));