Skip to content

Commit 8b64056

Browse files
Oliver Hartkoppdavem330
authored andcommitted
can: deny filterlist access on non-CAN interfaces
In commit 20dd385 "can: Speed up CAN frame receiption by using ml_priv" the formerly used hlist of receiver lists for each CAN netdevice has been replaced. The hlist content ensured only CAN netdevices to be accessed by the can_rx_(un)register() functions which accidently dropped away together with the hlist receiver implementation. This patch re-introduces the check for CAN netdevices in can_rx_(un)register(). Signed-off-by: Oliver Hartkopp <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 44298ec commit 8b64056

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/can/af_can.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ int can_rx_register(struct net_device *dev, canid_t can_id, canid_t mask,
415415

416416
/* insert new receiver (dev,canid,mask) -> (func,data) */
417417

418+
if (dev && dev->type != ARPHRD_CAN)
419+
return -ENODEV;
420+
418421
r = kmem_cache_alloc(rcv_cache, GFP_KERNEL);
419422
if (!r)
420423
return -ENOMEM;
@@ -478,6 +481,9 @@ void can_rx_unregister(struct net_device *dev, canid_t can_id, canid_t mask,
478481
struct hlist_node *next;
479482
struct dev_rcv_lists *d;
480483

484+
if (dev && dev->type != ARPHRD_CAN)
485+
return;
486+
481487
spin_lock(&can_rcvlists_lock);
482488

483489
d = find_dev_rcv_lists(dev);

0 commit comments

Comments
 (0)