can: remove WARN() statement from list operation sanity check
Subsystems (4)
Oliver Hartkopp
maintainerPATCH 1/1 can: remove WARN() statement from list operation sanity check
To detect potential bugs in CAN protocol implementations (double removal of receiver entries) a WARN() statement has been used if no matching list item was found for removal.
The fault injection issued by syzkaller was able to create a situation where the closing of a socket runs simultaneously to the notifier call chain for removing the CAN network device in use.
This case is very unlikely in real life but it doesn't break anything. Therefore we just replace the WARN() statement with pr_warn() to preserve the notification for the CAN protocol development.
--- net/can/af_can.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/can/af_can.c +5 -2
@@ -539,14 +539,17 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,break ; }/* Check for bugs in CAN protocol implementations using af_can.c: * 'rcv' will be NULL if no matching list item was found for removal. +* As this case may potentially happen when closing a socket while +* the notifier for removing the CAN netdev is running we just print +* a warning here. Reported by syskaller (see commit message) */ if (!rcv) { -WARN (1 ,"BUG: receive list entry not found for dev %s, id %03X, mask %03X\n" , -DNAME (dev), can_id, mask); +pr_warn ("can: receive list entry not found for dev %s, id %03X, mask %03X\n" , +DNAME (dev), can_id, mask); goto out; }hlist_del_rcu (&rcv->list); dev_rcv_lists->entries--;
Signature · 1 line
2.29.2
Marc Kleine-Budde
maintainerQuoted 8 lines · Oliver Hartkopp
To detect potential bugs in CAN protocol implementations (double removal of receiver entries) a
WARN()statement has been used if no matching list item was found for removal.The fault injection issued by syzkaller was able to create a situation where the closing of a socket runs simultaneously to the notifier call chain for removing the CAN network device in use.
Quoted 8 lines
This case is very unlikely in real life but it doesn't break anything. Therefore we just replace the
WARN()statement withpr_warn()to preserve the notification for the CAN protocol development.Reported-by [email protected]Reported-by [email protected]Reported-by [email protected]Signed-off-by Oliver Hartkopp <[email protected]>
applied to can/testing.
tnx,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Marc Kleine-Budde
maintainerQuoted 25 lines · Oliver Hartkopp
To detect potential bugs in CAN protocol implementations (double removal of receiver entries) a
WARN()statement has been used if no matching list item was found for removal.The fault injection issued by syzkaller was able to create a situation where the closing of a socket runs simultaneously to the notifier call chain for removing the CAN network device in use.
This case is very unlikely in real life but it doesn't break anything. Therefore we just replace the
WARN()statement withpr_warn()to preserve the notification for the CAN protocol development.Reported-by [email protected]Reported-by [email protected]Reported-by [email protected]Signed-off-by Oliver Hartkopp <[email protected]>--- net/can/af_can.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)net/can/af_can.c +0
-0
net/can/af_can.c void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, · line 546
Quoted 8 lines
net/can/af_can.c +3
-0@@ -539,14 +539,17 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,break ; }/* Check for bugs in CAN protocol implementations using af_can.c: * 'rcv' will be NULL if no matching list item was found for removal. +* As this case may potentially happen when closing a socket while +* the notifier for removing the CAN netdev is running we just print +* a warning here. Reported by syskaller (see commit message)
I've removed the "Reported by syskaller (see commit message)" while applying the patch, to keep this comment short and to the point. Use tig/git blame (or any other future tool) to figure out the commit message for details :D
net/can/af_can.c void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, · line 555
Quoted 12 lines
net/can/af_can.c +2
-2*/ if (!rcv) { -WARN (1 ,"BUG: receive list entry not found for dev %s, id %03X, mask %03X\n" , -DNAME (dev), can_id, mask); +pr_warn ("can: receive list entry not found for dev %s, id %03X, mask %03X\n" , +DNAME (dev), can_id, mask); goto out; }hlist_del_rcu (&rcv->list); dev_rcv_lists->entries--;
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Oliver Hartkopp
maintainerQuoted 9 lines · Marc Kleine-Budde
net/can/af_can.c void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, · line 546
Quoted 5 lines
/* Check for bugs in CAN protocol implementations using
af_can.c:
* 'rcv' will be NULL if no matching list item was found for removal.net/can/af_can.c +3
-0+* As this case may potentially happen when closing a socket while +* the notifier for removing the CAN netdev is running we just print +* a warning here. Reported by syskaller (see commit message) I've removed the "Reported by syskaller (see commit message)" while applying the patch, to keep this comment short and to the point. Use tig/git blame (or any other future tool) to figure out the commit message for details :D
Is fine for me ;-)
Thanks Marc!