Re: [syzbot] [net?] possible deadlock in hsr_dev_xmit (2)

From: Hillf Danton
Date: Mon Apr 01 2024 - 18:44:52 EST


On Sun, 31 Mar 2024 23:11:27 -0700
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 480e035fc4c7 Merge tag 'drm-next-2024-03-13' of https://gi..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15e0f5c3180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 480e035fc4c7

--- x/net/hsr/hsr_device.c
+++ y/net/hsr/hsr_device.c
@@ -220,15 +220,19 @@ static netdev_tx_t hsr_dev_xmit(struct s
{
struct hsr_priv *hsr = netdev_priv(dev);
struct hsr_port *master;
+ static int depth = 0;

master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
if (master) {
skb->dev = master->dev;
skb_reset_mac_header(skb);
skb_reset_mac_len(skb);
- spin_lock_bh(&hsr->seqnr_lock);
+ local_bh_disable();
+ spin_lock_nested(&hsr->seqnr_lock, ++depth);
hsr_forward_skb(skb, master);
- spin_unlock_bh(&hsr->seqnr_lock);
+ --depth;
+ spin_unlock(&hsr->seqnr_lock);
+ local_bh_enable();
} else {
dev_core_stats_tx_dropped_inc(dev);
dev_kfree_skb_any(skb);
--