Skip to content

Commit 78b7b99

Browse files
q2venPaolo Abeni
authored andcommitted
vxlan: Handle error of rtnl_register_module().
Since introduced, vxlan_vnifilter_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: f9c4bb0 ("vxlan: vni filtering support on collect metadata device") Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 07cc7b0 commit 78b7b99

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

drivers/net/vxlan/vxlan_core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4913,9 +4913,13 @@ static int __init vxlan_init_module(void)
49134913
if (rc)
49144914
goto out4;
49154915

4916-
vxlan_vnifilter_init();
4916+
rc = vxlan_vnifilter_init();
4917+
if (rc)
4918+
goto out5;
49174919

49184920
return 0;
4921+
out5:
4922+
rtnl_link_unregister(&vxlan_link_ops);
49194923
out4:
49204924
unregister_switchdev_notifier(&vxlan_switchdev_notifier_block);
49214925
out3:

drivers/net/vxlan/vxlan_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int vxlan_vni_in_use(struct net *src_net, struct vxlan_dev *vxlan,
202202
int vxlan_vnigroup_init(struct vxlan_dev *vxlan);
203203
void vxlan_vnigroup_uninit(struct vxlan_dev *vxlan);
204204

205-
void vxlan_vnifilter_init(void);
205+
int vxlan_vnifilter_init(void);
206206
void vxlan_vnifilter_uninit(void);
207207
void vxlan_vnifilter_count(struct vxlan_dev *vxlan, __be32 vni,
208208
struct vxlan_vni_node *vninode,

drivers/net/vxlan/vxlan_vnifilter.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -992,19 +992,18 @@ static int vxlan_vnifilter_process(struct sk_buff *skb, struct nlmsghdr *nlh,
992992
return err;
993993
}
994994

995-
void vxlan_vnifilter_init(void)
995+
static const struct rtnl_msg_handler vxlan_vnifilter_rtnl_msg_handlers[] = {
996+
{THIS_MODULE, PF_BRIDGE, RTM_GETTUNNEL, NULL, vxlan_vnifilter_dump, 0},
997+
{THIS_MODULE, PF_BRIDGE, RTM_NEWTUNNEL, vxlan_vnifilter_process, NULL, 0},
998+
{THIS_MODULE, PF_BRIDGE, RTM_DELTUNNEL, vxlan_vnifilter_process, NULL, 0},
999+
};
1000+
1001+
int vxlan_vnifilter_init(void)
9961002
{
997-
rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_GETTUNNEL, NULL,
998-
vxlan_vnifilter_dump, 0);
999-
rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_NEWTUNNEL,
1000-
vxlan_vnifilter_process, NULL, 0);
1001-
rtnl_register_module(THIS_MODULE, PF_BRIDGE, RTM_DELTUNNEL,
1002-
vxlan_vnifilter_process, NULL, 0);
1003+
return rtnl_register_many(vxlan_vnifilter_rtnl_msg_handlers);
10031004
}
10041005

10051006
void vxlan_vnifilter_uninit(void)
10061007
{
1007-
rtnl_unregister(PF_BRIDGE, RTM_GETTUNNEL);
1008-
rtnl_unregister(PF_BRIDGE, RTM_NEWTUNNEL);
1009-
rtnl_unregister(PF_BRIDGE, RTM_DELTUNNEL);
1008+
rtnl_unregister_many(vxlan_vnifilter_rtnl_msg_handlers);
10101009
}

0 commit comments

Comments
 (0)