Skip to content

Commit 5fe1165

Browse files
author
CKI Backport Bot
committed
ipv6: mcast: annotate data-race around psf->sf_count[MCAST_XXX]
JIRA: https://issues.redhat.com/browse/RHEL-84540 commit 00bf203 Author: Eric Dumazet <edumazet@google.com> Date: Tue Dec 10 18:33:52 2024 +0000 ipv6: mcast: annotate data-race around psf->sf_count[MCAST_XXX] psf->sf_count[MCAST_XXX] fields are read locklessly from ipv6_chk_mcast_addr() and igmp6_mcf_seq_show(). Add READ_ONCE() and WRITE_ONCE() annotations accordingly. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://patch.msgid.link/20241210183352.86530-4-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent 58ae8c3 commit 5fe1165

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

net/ipv6/mcast.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,8 @@ bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
10371037
break;
10381038
}
10391039
if (psf)
1040-
rv = psf->sf_count[MCAST_INCLUDE] ||
1041-
psf->sf_count[MCAST_EXCLUDE] !=
1040+
rv = READ_ONCE(psf->sf_count[MCAST_INCLUDE]) ||
1041+
READ_ONCE(psf->sf_count[MCAST_EXCLUDE]) !=
10421042
READ_ONCE(mc->mca_sfcount[MCAST_EXCLUDE]);
10431043
else
10441044
rv = READ_ONCE(mc->mca_sfcount[MCAST_EXCLUDE]) != 0;
@@ -2287,7 +2287,7 @@ static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
22872287
/* source filter not found, or count wrong => bug */
22882288
return -ESRCH;
22892289
}
2290-
psf->sf_count[sfmode]--;
2290+
WRITE_ONCE(psf->sf_count[sfmode], psf->sf_count[sfmode] - 1);
22912291
if (!psf->sf_count[MCAST_INCLUDE] && !psf->sf_count[MCAST_EXCLUDE]) {
22922292
struct inet6_dev *idev = pmc->idev;
22932293

@@ -2393,7 +2393,7 @@ static int ip6_mc_add1_src(struct ifmcaddr6 *pmc, int sfmode,
23932393
rcu_assign_pointer(pmc->mca_sources, psf);
23942394
}
23952395
}
2396-
psf->sf_count[sfmode]++;
2396+
WRITE_ONCE(psf->sf_count[sfmode], psf->sf_count[sfmode] + 1);
23972397
return 0;
23982398
}
23992399

@@ -3079,8 +3079,8 @@ static int igmp6_mcf_seq_show(struct seq_file *seq, void *v)
30793079
state->dev->ifindex, state->dev->name,
30803080
&state->im->mca_addr,
30813081
&psf->sf_addr,
3082-
psf->sf_count[MCAST_INCLUDE],
3083-
psf->sf_count[MCAST_EXCLUDE]);
3082+
READ_ONCE(psf->sf_count[MCAST_INCLUDE]),
3083+
READ_ONCE(psf->sf_count[MCAST_EXCLUDE]));
30843084
}
30853085
return 0;
30863086
}

0 commit comments

Comments
 (0)