hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
kernel/net/ipv4/tcp_ipv4.c
....@@ -62,6 +62,7 @@
6262 #include <linux/init.h>
6363 #include <linux/times.h>
6464 #include <linux/slab.h>
65
+#include <linux/locallock.h>
6566
6667 #include <net/net_namespace.h>
6768 #include <net/icmp.h>
....@@ -637,6 +638,7 @@
637638 }
638639 EXPORT_SYMBOL(tcp_v4_send_check);
639640
641
+static DEFINE_LOCAL_IRQ_LOCK(tcp_sk_lock);
640642 /*
641643 * This routine will send an RST to the other tcp.
642644 *
....@@ -771,6 +773,7 @@
771773 arg.tos = ip_hdr(skb)->tos;
772774 arg.uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL);
773775 local_bh_disable();
776
+ local_lock(tcp_sk_lock);
774777 ctl_sk = *this_cpu_ptr(net->ipv4.tcp_sk);
775778 if (sk)
776779 ctl_sk->sk_mark = (sk->sk_state == TCP_TIME_WAIT) ?
....@@ -783,6 +786,7 @@
783786 ctl_sk->sk_mark = 0;
784787 __TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
785788 __TCP_INC_STATS(net, TCP_MIB_OUTRSTS);
789
+ local_unlock(tcp_sk_lock);
786790 local_bh_enable();
787791
788792 #ifdef CONFIG_TCP_MD5SIG
....@@ -863,6 +867,7 @@
863867 arg.tos = tos;
864868 arg.uid = sock_net_uid(net, sk_fullsock(sk) ? sk : NULL);
865869 local_bh_disable();
870
+ local_lock(tcp_sk_lock);
866871 ctl_sk = *this_cpu_ptr(net->ipv4.tcp_sk);
867872 if (sk)
868873 ctl_sk->sk_mark = (sk->sk_state == TCP_TIME_WAIT) ?
....@@ -874,6 +879,7 @@
874879
875880 ctl_sk->sk_mark = 0;
876881 __TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
882
+ local_unlock(tcp_sk_lock);
877883 local_bh_enable();
878884 }
879885