Skip to content

Commit ad38f6a

Browse files
Jonathan T. LooneyJonathan T. Looney
authored andcommitted
tcp: close two minor races with debug messages
The syncache entry is locked by the hash bucket lock. After running SCH_UNLOCK(), we have no guarantee that the syncache entry still exists. Resolve the race by moving SCH_UNLOCK() after the log() call which reads variables from the syncache entry. Reviewed by: rrs, tuexen, Nick Banks Sponsored by: Netflix MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52868
1 parent 5d210f3 commit ad38f6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sys/netinet/tcp_syncache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,14 +1201,14 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
12011201
*/
12021202
if (sc->sc_flags & SCF_TIMESTAMP && to->to_flags & TOF_TS &&
12031203
TSTMP_LT(to->to_tsval, sc->sc_tsreflect)) {
1204-
SCH_UNLOCK(sch);
12051204
if ((s = tcp_log_addrs(inc, th, NULL, NULL))) {
12061205
log(LOG_DEBUG,
12071206
"%s; %s: SEG.TSval %u < TS.Recent %u, "
12081207
"segment dropped\n", s, __func__,
12091208
to->to_tsval, sc->sc_tsreflect);
12101209
free(s, M_TCPLOG);
12111210
}
1211+
SCH_UNLOCK(sch);
12121212
return (-1); /* Do not send RST */
12131213
}
12141214

@@ -1280,11 +1280,11 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
12801280
* SEG.ACK must match our initial send sequence number + 1.
12811281
*/
12821282
if (th->th_ack != sc->sc_iss + 1) {
1283-
SCH_UNLOCK(sch);
12841283
if ((s = tcp_log_addrs(inc, th, NULL, NULL)))
12851284
log(LOG_DEBUG, "%s; %s: ACK %u != ISS+1 %u, "
12861285
"segment rejected\n",
12871286
s, __func__, th->th_ack, sc->sc_iss + 1);
1287+
SCH_UNLOCK(sch);
12881288
goto failed;
12891289
}
12901290

0 commit comments

Comments
 (0)