Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit cba5e43

Browse files
q2venPaolo Abeni
authored andcommitted
bridge: Handle error of rtnl_register_module().
Since introduced, br_vlan_rtnl_init() has been ignoring the returned value of rtnl_register_module(), which could fail silently. Handling the error allows users to view a module as an all-or-nothing thing in terms of the rtnetlink functionality. This prevents syzkaller from reporting spurious errors from its tests, where OOM often occurs and module is automatically loaded. Let's handle the errors by rtnl_register_many(). Fixes: 8dcea18 ("net: bridge: vlan: add rtm definitions and dump support") Fixes: f26b296 ("net: bridge: vlan: add new rtm message support") Fixes: adb3ce9 ("net: bridge: vlan: add del rtm message support") Signed-off-by: Kuniyuki Iwashima <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 78b7b99 commit cba5e43

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

net/bridge/br_netlink.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,10 @@ int __init br_netlink_init(void)
19201920
{
19211921
int err;
19221922

1923-
br_vlan_rtnl_init();
1923+
err = br_vlan_rtnl_init();
1924+
if (err)
1925+
goto out;
1926+
19241927
rtnl_af_register(&br_af_ops);
19251928

19261929
err = rtnl_link_register(&br_link_ops);
@@ -1931,6 +1934,7 @@ int __init br_netlink_init(void)
19311934

19321935
out_af:
19331936
rtnl_af_unregister(&br_af_ops);
1937+
out:
19341938
return err;
19351939
}
19361940

net/bridge/br_private.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ void br_vlan_get_stats(const struct net_bridge_vlan *v,
15711571
void br_vlan_port_event(struct net_bridge_port *p, unsigned long event);
15721572
int br_vlan_bridge_event(struct net_device *dev, unsigned long event,
15731573
void *ptr);
1574-
void br_vlan_rtnl_init(void);
1574+
int br_vlan_rtnl_init(void);
15751575
void br_vlan_rtnl_uninit(void);
15761576
void br_vlan_notify(const struct net_bridge *br,
15771577
const struct net_bridge_port *p,
@@ -1802,8 +1802,9 @@ static inline int br_vlan_bridge_event(struct net_device *dev,
18021802
return 0;
18031803
}
18041804

1805-
static inline void br_vlan_rtnl_init(void)
1805+
static inline int br_vlan_rtnl_init(void)
18061806
{
1807+
return 0;
18071808
}
18081809

18091810
static inline void br_vlan_rtnl_uninit(void)

net/bridge/br_vlan.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,19 +2296,18 @@ static int br_vlan_rtm_process(struct sk_buff *skb, struct nlmsghdr *nlh,
22962296
return err;
22972297
}
22982298

2299-
void br_vlan_rtnl_init(void)
2299+
static const struct rtnl_msg_handler br_vlan_rtnl_msg_handlers[] = {
2300+
{THIS_MODULE, PF_BRIDGE, RTM_NEWVLAN, br_vlan_rtm_process, NULL, 0},
2301+
{THIS_MODULE, PF_BRIDGE, RTM_DELVLAN, br_vlan_rtm_process, NULL, 0},
2302+
{THIS_MODULE, PF_BRIDGE, RTM_GETVLAN, NULL, br_vlan_rtm_dump, 0},
2303+
};
2304+
2305+
int br_vlan_rtnl_init(void)
23002306
{
2301-
rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_GETVLAN, NULL,
2302-
br_vlan_rtm_dump, 0);
2303-
rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_NEWVLAN,
2304-
br_vlan_rtm_process, NULL, 0);
2305-
rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_DELVLAN,
2306-
br_vlan_rtm_process, NULL, 0);
2307+
return rtnl_register_many(br_vlan_rtnl_msg_handlers);
23072308
}
23082309

23092310
void br_vlan_rtnl_uninit(void)
23102311
{
2311-
rtnl_unregister(PF_BRIDGE, RTM_GETVLAN);
2312-
rtnl_unregister(PF_BRIDGE, RTM_NEWVLAN);
2313-
rtnl_unregister(PF_BRIDGE, RTM_DELVLAN);
2312+
rtnl_unregister_many(br_vlan_rtnl_msg_handlers);
23142313
}

0 commit comments

Comments
 (0)