hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/ipv4/tcp_minisocks.c
....@@ -523,7 +523,7 @@
523523 newtp->max_window = newtp->snd_wnd;
524524
525525 if (newtp->rx_opt.tstamp_ok) {
526
- newtp->rx_opt.ts_recent = req->ts_recent;
526
+ newtp->rx_opt.ts_recent = READ_ONCE(req->ts_recent);
527527 newtp->rx_opt.ts_recent_stamp = ktime_get_seconds();
528528 newtp->tcp_header_len = sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED;
529529 } else {
....@@ -565,6 +565,9 @@
565565 * validation and inside tcp_v4_reqsk_send_ack(). Can we do better?
566566 *
567567 * We don't need to initialize tmp_opt.sack_ok as we don't use the results
568
+ *
569
+ * Note: If @fastopen is true, this can be called from process context.
570
+ * Otherwise, this is from BH context.
568571 */
569572
570573 struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
....@@ -583,7 +586,7 @@
583586 tcp_parse_options(sock_net(sk), skb, &tmp_opt, 0, NULL);
584587
585588 if (tmp_opt.saw_tstamp) {
586
- tmp_opt.ts_recent = req->ts_recent;
589
+ tmp_opt.ts_recent = READ_ONCE(req->ts_recent);
587590 if (tmp_opt.rcv_tsecr)
588591 tmp_opt.rcv_tsecr -= tcp_rsk(req)->ts_off;
589592 /* We do not store true stamp, but it is not required,
....@@ -717,14 +720,17 @@
717720 &tcp_rsk(req)->last_oow_ack_time))
718721 req->rsk_ops->send_ack(sk, skb, req);
719722 if (paws_reject)
720
- __NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED);
723
+ NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED);
721724 return NULL;
722725 }
723726
724727 /* In sequence, PAWS is OK. */
725728
729
+ /* TODO: We probably should defer ts_recent change once
730
+ * we take ownership of @req.
731
+ */
726732 if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, tcp_rsk(req)->rcv_nxt))
727
- req->ts_recent = tmp_opt.rcv_tsval;
733
+ WRITE_ONCE(req->ts_recent, tmp_opt.rcv_tsval);
728734
729735 if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn) {
730736 /* Truncate SYN, it is out of window starting
....@@ -736,7 +742,7 @@
736742 * "fourth, check the SYN bit"
737743 */
738744 if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN)) {
739
- __TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
745
+ TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
740746 goto embryonic_reset;
741747 }
742748