Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipv4: igmp: annotate data-races around idev->mr_maxdelay

idev->mr_maxdelay is read and written locklessly,
add READ_ONCE()/WRITE_ONCE() annotations.

While we are at it, make this field an u32.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20260122172247.2429403-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
e4faaf65 05413022

+3 -3
+1 -1
include/linux/inetdevice.h
··· 38 38 struct ip_mc_list *mc_tomb; 39 39 unsigned long mr_v1_seen; 40 40 unsigned long mr_v2_seen; 41 - unsigned long mr_maxdelay; 42 41 unsigned long mr_qi; /* Query Interval */ 43 42 unsigned long mr_qri; /* Query Response Interval */ 44 43 unsigned char mr_qrv; /* Query Robustness Variable */ 45 44 unsigned char mr_gq_running; 45 + u32 mr_maxdelay; 46 46 u32 mr_ifc_count; 47 47 struct timer_list mr_gq_timer; /* general query timer */ 48 48 struct timer_list mr_ifc_timer; /* interface change timer */
+2 -2
net/ipv4/igmp.c
··· 227 227 228 228 static void igmp_gq_start_timer(struct in_device *in_dev) 229 229 { 230 - int tv = get_random_u32_below(in_dev->mr_maxdelay); 230 + int tv = get_random_u32_below(READ_ONCE(in_dev->mr_maxdelay)); 231 231 unsigned long exp = jiffies + tv + 2; 232 232 233 233 if (in_dev->mr_gq_running && ··· 1009 1009 max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE); 1010 1010 if (!max_delay) 1011 1011 max_delay = 1; /* can't mod w/ 0 */ 1012 - in_dev->mr_maxdelay = max_delay; 1012 + WRITE_ONCE(in_dev->mr_maxdelay, max_delay); 1013 1013 1014 1014 /* RFC3376, 4.1.6. QRV and 4.1.7. QQIC, when the most recently 1015 1015 * received value was zero, use the default or statically