@@ -328,9 +328,9 @@ ctnetlink_dump_timestamp(struct sk_buff *skb, const struct nf_conn *ct)
328328}
329329
330330#ifdef CONFIG_NF_CONNTRACK_MARK
331- static int ctnetlink_dump_mark (struct sk_buff * skb , const struct nf_conn * ct )
331+ static int ctnetlink_dump_mark (struct sk_buff * skb , u32 mark )
332332{
333- if (nla_put_be32 (skb , CTA_MARK , htonl (ct -> mark )))
333+ if (nla_put_be32 (skb , CTA_MARK , htonl (mark )))
334334 goto nla_put_failure ;
335335 return 0 ;
336336
@@ -543,7 +543,7 @@ static int ctnetlink_dump_extinfo(struct sk_buff *skb,
543543static int ctnetlink_dump_info (struct sk_buff * skb , struct nf_conn * ct )
544544{
545545 if (ctnetlink_dump_status (skb , ct ) < 0 ||
546- ctnetlink_dump_mark (skb , ct ) < 0 ||
546+ ctnetlink_dump_mark (skb , READ_ONCE ( ct -> mark ) ) < 0 ||
547547 ctnetlink_dump_secctx (skb , ct ) < 0 ||
548548 ctnetlink_dump_id (skb , ct ) < 0 ||
549549 ctnetlink_dump_use (skb , ct ) < 0 ||
@@ -722,6 +722,7 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
722722 struct sk_buff * skb ;
723723 unsigned int type ;
724724 unsigned int flags = 0 , group ;
725+ u32 mark ;
725726 int err ;
726727
727728 if (events & (1 << IPCT_DESTROY )) {
@@ -826,8 +827,9 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
826827 }
827828
828829#ifdef CONFIG_NF_CONNTRACK_MARK
829- if ((events & (1 << IPCT_MARK ) || ct -> mark )
830- && ctnetlink_dump_mark (skb , ct ) < 0 )
830+ mark = READ_ONCE (ct -> mark );
831+ if ((events & (1 << IPCT_MARK ) || mark ) &&
832+ ctnetlink_dump_mark (skb , mark ) < 0 )
831833 goto nla_put_failure ;
832834#endif
833835 nlmsg_end (skb , nlh );
@@ -1154,7 +1156,7 @@ static int ctnetlink_filter_match(struct nf_conn *ct, void *data)
11541156 }
11551157
11561158#ifdef CONFIG_NF_CONNTRACK_MARK
1157- if ((ct -> mark & filter -> mark .mask ) != filter -> mark .val )
1159+ if ((READ_ONCE ( ct -> mark ) & filter -> mark .mask ) != filter -> mark .val )
11581160 goto ignore_entry ;
11591161#endif
11601162 status = (u32 )READ_ONCE (ct -> status );
@@ -2002,9 +2004,9 @@ static void ctnetlink_change_mark(struct nf_conn *ct,
20022004 mask = ~ntohl (nla_get_be32 (cda [CTA_MARK_MASK ]));
20032005
20042006 mark = ntohl (nla_get_be32 (cda [CTA_MARK ]));
2005- newmark = (ct -> mark & mask ) ^ mark ;
2006- if (newmark != ct -> mark )
2007- ct -> mark = newmark ;
2007+ newmark = (READ_ONCE ( ct -> mark ) & mask ) ^ mark ;
2008+ if (newmark != READ_ONCE ( ct -> mark ) )
2009+ WRITE_ONCE ( ct -> mark , newmark ) ;
20082010}
20092011#endif
20102012
@@ -2669,6 +2671,7 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
26692671{
26702672 const struct nf_conntrack_zone * zone ;
26712673 struct nlattr * nest_parms ;
2674+ u32 mark ;
26722675
26732676 zone = nf_ct_zone (ct );
26742677
@@ -2730,7 +2733,8 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
27302733 goto nla_put_failure ;
27312734
27322735#ifdef CONFIG_NF_CONNTRACK_MARK
2733- if (ct -> mark && ctnetlink_dump_mark (skb , ct ) < 0 )
2736+ mark = READ_ONCE (ct -> mark );
2737+ if (mark && ctnetlink_dump_mark (skb , mark ) < 0 )
27342738 goto nla_put_failure ;
27352739#endif
27362740 if (ctnetlink_dump_labels (skb , ct ) < 0 )
0 commit comments