Skip to content

Commit

Permalink
net: hsr: Use the seqnr lock for frames received via interlink port.
Browse files Browse the repository at this point in the history
syzbot reported that the seqnr_lock is not acquire for frames received
over the interlink port. In the interlink case a new seqnr is generated
and assigned to the frame.
Frames, which are received over the slave port have already a sequence
number assigned so the lock is not required.

Acquire the hsr_priv::seqnr_lock during in the invocation of
hsr_forward_skb() if a packet has been received from the interlink port.

Reported-by: syzbot+3d602af7549af539274e@syzkaller.appspotmail.com
Closes: https://groups.google.com/g/syzkaller-bugs/c/KppVvGviGg4/m/EItSdCZdBAAJ
Fixes: 5055ccc ("net: hsr: Provide RedBox support (HSR-SAN)")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Tested-by: Lukasz Majewski <lukma@denx.de>
Link: https://patch.msgid.link/20240906132816.657485-2-bigeasy@linutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Sebastian Andrzej Siewior authored and Jakub Kicinski committed Sep 11, 2024
1 parent a18c097 commit 430d67b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion net/hsr/hsr_slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,16 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
skb_set_network_header(skb, ETH_HLEN + HSR_HLEN);
skb_reset_mac_len(skb);

hsr_forward_skb(skb, port);
/* Only the frames received over the interlink port will assign a
* sequence number and require synchronisation vs other sender.
*/
if (port->type == HSR_PT_INTERLINK) {
spin_lock_bh(&hsr->seqnr_lock);
hsr_forward_skb(skb, port);
spin_unlock_bh(&hsr->seqnr_lock);
} else {
hsr_forward_skb(skb, port);
}

finish_consume:
return RX_HANDLER_CONSUMED;
Expand Down

0 comments on commit 430d67b

Please sign in to comment.