hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/include/linux/netfilter/x_tables.h
....@@ -6,6 +6,7 @@
66 #include <linux/netdevice.h>
77 #include <linux/static_key.h>
88 #include <linux/netfilter.h>
9
+#include <linux/locallock.h>
910 #include <uapi/linux/netfilter/x_tables.h>
1011
1112 /* Test a struct->invflags and a boolean for inequality */
....@@ -345,6 +346,8 @@
345346 */
346347 DECLARE_PER_CPU(seqcount_t, xt_recseq);
347348
349
+DECLARE_LOCAL_IRQ_LOCK(xt_write_lock);
350
+
348351 /* xt_tee_enabled - true if x_tables needs to handle reentrancy
349352 *
350353 * Enabled if current ip(6)tables ruleset has at least one -j TEE rule.
....@@ -364,6 +367,9 @@
364367 static inline unsigned int xt_write_recseq_begin(void)
365368 {
366369 unsigned int addend;
370
+
371
+ /* RT protection */
372
+ local_lock(xt_write_lock);
367373
368374 /*
369375 * Low order bit of sequence is set if we already
....@@ -395,6 +401,7 @@
395401 /* this is kind of a write_seqcount_end(), but addend is 0 or 1 */
396402 smp_wmb();
397403 __this_cpu_add(xt_recseq.sequence, addend);
404
+ local_unlock(xt_write_lock);
398405 }
399406
400407 /*