Skip to content

Commit bbae061

Browse files
idoschsmb49
authored andcommitted
vxlan: Annotate FDB data races
BugLink: https://bugs.launchpad.net/bugs/2115678 [ Upstream commit f6205f8215f12a96518ac9469ff76294ae7bd612 ] The 'used' and 'updated' fields in the FDB entry structure can be accessed concurrently by multiple threads, leading to reports such as [1]. Can be reproduced using [2]. Suppress these reports by annotating these accesses using READ_ONCE() / WRITE_ONCE(). [1] BUG: KCSAN: data-race in vxlan_xmit / vxlan_xmit write to 0xffff942604d263a8 of 8 bytes by task 286 on cpu 0: vxlan_xmit+0xb29/0x2380 dev_hard_start_xmit+0x84/0x2f0 __dev_queue_xmit+0x45a/0x1650 packet_xmit+0x100/0x150 packet_sendmsg+0x2114/0x2ac0 __sys_sendto+0x318/0x330 __x64_sys_sendto+0x76/0x90 x64_sys_call+0x14e8/0x1c00 do_syscall_64+0x9e/0x1a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f read to 0xffff942604d263a8 of 8 bytes by task 287 on cpu 2: vxlan_xmit+0xadf/0x2380 dev_hard_start_xmit+0x84/0x2f0 __dev_queue_xmit+0x45a/0x1650 packet_xmit+0x100/0x150 packet_sendmsg+0x2114/0x2ac0 __sys_sendto+0x318/0x330 __x64_sys_sendto+0x76/0x90 x64_sys_call+0x14e8/0x1c00 do_syscall_64+0x9e/0x1a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f value changed: 0x00000000fffbac6e -> 0x00000000fffbac6f Reported by Kernel Concurrency Sanitizer on: CPU: 2 UID: 0 PID: 287 Comm: mausezahn Not tainted 6.13.0-rc7-01544-gb4b270f11a02 #5 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-3.fc41 04/01/2014 [2] #!/bin/bash set +H echo whitelist > /sys/kernel/debug/kcsan echo !vxlan_xmit > /sys/kernel/debug/kcsan ip link add name vx0 up type vxlan id 10010 dstport 4789 local 192.0.2.1 bridge fdb add 00:11:22:33:44:55 dev vx0 self static dst 198.51.100.1 taskset -c 0 mausezahn vx0 -a own -b 00:11:22:33:44:55 -c 0 -q & taskset -c 2 mausezahn vx0 -a own -b 00:11:22:33:44:55 -c 0 -q & Reviewed-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Link: https://patch.msgid.link/20250204145549.1216254-2-idosch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> CVE-2025-38037 Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
1 parent 7ebfbc9 commit bbae061

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/net/vxlan/vxlan_core.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
389389
be32_to_cpu(fdb->vni)))
390390
goto nla_put_failure;
391391

392-
ci.ndm_used = jiffies_to_clock_t(now - fdb->used);
392+
ci.ndm_used = jiffies_to_clock_t(now - READ_ONCE(fdb->used));
393393
ci.ndm_confirmed = 0;
394-
ci.ndm_updated = jiffies_to_clock_t(now - fdb->updated);
394+
ci.ndm_updated = jiffies_to_clock_t(now - READ_ONCE(fdb->updated));
395395
ci.ndm_refcnt = 0;
396396

397397
if (nla_put(skb, NDA_CACHEINFO, sizeof(ci), &ci))
@@ -596,8 +596,8 @@ static struct vxlan_fdb *vxlan_find_mac(struct vxlan_dev *vxlan,
596596
struct vxlan_fdb *f;
597597

598598
f = __vxlan_find_mac(vxlan, mac, vni);
599-
if (f && f->used != jiffies)
600-
f->used = jiffies;
599+
if (f && READ_ONCE(f->used) != jiffies)
600+
WRITE_ONCE(f->used, jiffies);
601601

602602
return f;
603603
}
@@ -1171,12 +1171,12 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,
11711171
!(f->flags & NTF_VXLAN_ADDED_BY_USER)) {
11721172
if (f->state != state) {
11731173
f->state = state;
1174-
f->updated = jiffies;
1174+
WRITE_ONCE(f->updated, jiffies);
11751175
notify = 1;
11761176
}
11771177
if (f->flags != fdb_flags) {
11781178
f->flags = fdb_flags;
1179-
f->updated = jiffies;
1179+
WRITE_ONCE(f->updated, jiffies);
11801180
notify = 1;
11811181
}
11821182
}
@@ -1210,7 +1210,7 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,
12101210
}
12111211

12121212
if (ndm_flags & NTF_USE)
1213-
f->used = jiffies;
1213+
WRITE_ONCE(f->used, jiffies);
12141214

12151215
if (notify) {
12161216
if (rd == NULL)
@@ -1643,7 +1643,7 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
16431643
src_mac, &rdst->remote_ip.sa, &src_ip->sa);
16441644

16451645
rdst->remote_ip = *src_ip;
1646-
f->updated = jiffies;
1646+
WRITE_ONCE(f->updated, jiffies);
16471647
vxlan_fdb_notify(vxlan, f, rdst, RTM_NEWNEIGH, true, NULL);
16481648
} else {
16491649
u32 hash_index = fdb_head_index(vxlan, src_mac, vni);
@@ -3036,7 +3036,7 @@ static void vxlan_cleanup(struct timer_list *t)
30363036
if (f->flags & NTF_EXT_LEARNED)
30373037
continue;
30383038

3039-
timeout = f->used + vxlan->cfg.age_interval * HZ;
3039+
timeout = READ_ONCE(f->used) + vxlan->cfg.age_interval * HZ;
30403040
if (time_before_eq(timeout, jiffies)) {
30413041
netdev_dbg(vxlan->dev,
30423042
"garbage collect %pM\n",

0 commit comments

Comments
 (0)