Skip to content

Commit b120e44

Browse files
edumazetkuba-moo
authored andcommitted
net: lapbether: handle NETDEV_PRE_TYPE_CHANGE
lapbeth_data_transmit() expects the underlying device type to be ARPHRD_ETHER. Returning NOTIFY_BAD from lapbeth_device_event() makes sure bonding driver can not break this expectation. Fixes: 872254d ("net/bonding: Enable bonding to enslave non ARPHRD_ETHER") Reported-by: syzbot+d8c285748fa7292580a9@syzkaller.appspotmail.com Closes: https://lore.kernel.org/netdev/69cd22a1.050a0220.70c3a.0002.GAE@google.com/T/#u Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Martin Schiller <ms@dev.tdt.de> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260402103519.1201565-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent e16a0d3 commit b120e44

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

drivers/net/wan/lapbether.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,33 +446,36 @@ static void lapbeth_free_device(struct lapbethdev *lapbeth)
446446
static int lapbeth_device_event(struct notifier_block *this,
447447
unsigned long event, void *ptr)
448448
{
449-
struct lapbethdev *lapbeth;
450449
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
450+
struct lapbethdev *lapbeth;
451451

452452
if (dev_net(dev) != &init_net)
453453
return NOTIFY_DONE;
454454

455-
if (!dev_is_ethdev(dev) && !lapbeth_get_x25_dev(dev))
455+
lapbeth = lapbeth_get_x25_dev(dev);
456+
if (!dev_is_ethdev(dev) && !lapbeth)
456457
return NOTIFY_DONE;
457458

458459
switch (event) {
459460
case NETDEV_UP:
460461
/* New ethernet device -> new LAPB interface */
461-
if (!lapbeth_get_x25_dev(dev))
462+
if (!lapbeth)
462463
lapbeth_new_device(dev);
463464
break;
464465
case NETDEV_GOING_DOWN:
465466
/* ethernet device closes -> close LAPB interface */
466-
lapbeth = lapbeth_get_x25_dev(dev);
467467
if (lapbeth)
468468
dev_close(lapbeth->axdev);
469469
break;
470470
case NETDEV_UNREGISTER:
471471
/* ethernet device disappears -> remove LAPB interface */
472-
lapbeth = lapbeth_get_x25_dev(dev);
473472
if (lapbeth)
474473
lapbeth_free_device(lapbeth);
475474
break;
475+
case NETDEV_PRE_TYPE_CHANGE:
476+
/* Our underlying device type must not change. */
477+
if (lapbeth)
478+
return NOTIFY_BAD;
476479
}
477480

478481
return NOTIFY_DONE;

0 commit comments

Comments
 (0)