Skip to content

Commit bdb19cd

Browse files
Wang Lianggregkh
authored andcommitted
net: bridge: fix soft lockup in br_multicast_query_expired()
[ Upstream commit d1547bf ] When set multicast_query_interval to a large value, the local variable 'time' in br_multicast_send_query() may overflow. If the time is smaller than jiffies, the timer will expire immediately, and then call mod_timer() again, which creates a loop and may trigger the following soft lockup issue. watchdog: BUG: soft lockup - CPU#1 stuck for 221s! [rb_consumer:66] CPU: 1 UID: 0 PID: 66 Comm: rb_consumer Not tainted 6.16.0+ #259 PREEMPT(none) Call Trace: <IRQ> __netdev_alloc_skb+0x2e/0x3a0 br_ip6_multicast_alloc_query+0x212/0x1b70 __br_multicast_send_query+0x376/0xac0 br_multicast_send_query+0x299/0x510 br_multicast_query_expired.constprop.0+0x16d/0x1b0 call_timer_fn+0x3b/0x2a0 __run_timers+0x619/0x950 run_timer_softirq+0x11c/0x220 handle_softirqs+0x18e/0x560 __irq_exit_rcu+0x158/0x1a0 sysvec_apic_timer_interrupt+0x76/0x90 </IRQ> This issue can be reproduced with: ip link add br0 type bridge echo 1 > /sys/class/net/br0/bridge/multicast_querier echo 0xffffffffffffffff > /sys/class/net/br0/bridge/multicast_query_interval ip link set dev br0 up The multicast_startup_query_interval can also cause this issue. Similar to the commit 99b4061 ("net: bridge: mcast: add and enforce query interval minimum"), add check for the query interval maximum to fix this issue. Link: https://lore.kernel.org/netdev/[email protected]/ Link: https://lore.kernel.org/netdev/[email protected]/ Fixes: d902eee ("bridge: Add multicast count/interval sysfs entries") Suggested-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: Wang Liang <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 87c36be commit bdb19cd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

net/bridge/br_multicast.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4808,6 +4808,14 @@ void br_multicast_set_query_intvl(struct net_bridge_mcast *brmctx,
48084808
intvl_jiffies = BR_MULTICAST_QUERY_INTVL_MIN;
48094809
}
48104810

4811+
if (intvl_jiffies > BR_MULTICAST_QUERY_INTVL_MAX) {
4812+
br_info(brmctx->br,
4813+
"trying to set multicast query interval above maximum, setting to %lu (%ums)\n",
4814+
jiffies_to_clock_t(BR_MULTICAST_QUERY_INTVL_MAX),
4815+
jiffies_to_msecs(BR_MULTICAST_QUERY_INTVL_MAX));
4816+
intvl_jiffies = BR_MULTICAST_QUERY_INTVL_MAX;
4817+
}
4818+
48114819
brmctx->multicast_query_interval = intvl_jiffies;
48124820
}
48134821

@@ -4824,6 +4832,14 @@ void br_multicast_set_startup_query_intvl(struct net_bridge_mcast *brmctx,
48244832
intvl_jiffies = BR_MULTICAST_STARTUP_QUERY_INTVL_MIN;
48254833
}
48264834

4835+
if (intvl_jiffies > BR_MULTICAST_STARTUP_QUERY_INTVL_MAX) {
4836+
br_info(brmctx->br,
4837+
"trying to set multicast startup query interval above maximum, setting to %lu (%ums)\n",
4838+
jiffies_to_clock_t(BR_MULTICAST_STARTUP_QUERY_INTVL_MAX),
4839+
jiffies_to_msecs(BR_MULTICAST_STARTUP_QUERY_INTVL_MAX));
4840+
intvl_jiffies = BR_MULTICAST_STARTUP_QUERY_INTVL_MAX;
4841+
}
4842+
48274843
brmctx->multicast_startup_query_interval = intvl_jiffies;
48284844
}
48294845

net/bridge/br_private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define BR_MULTICAST_DEFAULT_HASH_MAX 4096
3232
#define BR_MULTICAST_QUERY_INTVL_MIN msecs_to_jiffies(1000)
3333
#define BR_MULTICAST_STARTUP_QUERY_INTVL_MIN BR_MULTICAST_QUERY_INTVL_MIN
34+
#define BR_MULTICAST_QUERY_INTVL_MAX msecs_to_jiffies(86400000) /* 24 hours */
35+
#define BR_MULTICAST_STARTUP_QUERY_INTVL_MAX BR_MULTICAST_QUERY_INTVL_MAX
3436

3537
#define BR_HWDOM_MAX BITS_PER_LONG
3638

0 commit comments

Comments
 (0)