Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit ca15d28

Browse files
q2vengregkh
authored andcommitted
vxlan: Handle error of rtnl_register_module().
[ Upstream commit 78b7b99 ] 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 <kuniyu@amazon.com> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 35b72be commit ca15d28

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

drivers/net/vxlan/vxlan_core.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -4819,9 +4819,13 @@ static int __init vxlan_init_module(void)
48194819
if (rc)
48204820
goto out4;
48214821

4822-
vxlan_vnifilter_init();
4822+
rc = vxlan_vnifilter_init();
4823+
if (rc)
4824+
goto out5;
48234825

48244826
return 0;
4827+
out5:
4828+
rtnl_link_unregister(&vxlan_link_ops);
48254829
out4:
48264830
unregister_switchdev_notifier(&vxlan_switchdev_notifier_block);
48274831
out3:

drivers/net/vxlan/vxlan_private.h

+1-1
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

+9-10
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)