Skip to contentSkip to conversation

hsr: fix several bugs in generic netlink callback

PATCH Superseded Taehee Yoo 1 participant 2 messages Mar 13, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Taehee Yoo

author
#0 lore raw

cover hsr: fix several bugs in generic netlink callback

This patchset is to fix several bugs they are related in generic netlink callback in hsr module.

1. The first patch is to add missing rcu_read_lock() in hsr_get_node_{list/status}().
The hsr_get_node_{list/status}() are not protected by RTNL because they are callback functions of generic netlink.
But it calls __dev_get_by_index() without acquiring RTNL. So, it would use unsafe data.

2. The second patch is to avoid failure of hsr_get_node_list(). hsr_get_node_list() is a callback of generic netlink and it is used to get node information in userspace.
But, if there are so many nodes, it fails because of buffer size. So, in this patch, restart routine is added.

3. The third patch is to set .netnsok flag to true.
If .netnsok flag is false, non-init_net namespace is not allowed to operate generic netlink operations.
So, currently, non-init_net namespace has no way to get node information because .netnsok is false in the current hsr code.

Taehee Yoo (3):
hsr: use rcu_read_lock() in hsr_get_node_{list/status}()
hsr: add restart routine into hsr_get_node_list()
hsr: set .netnsok flag

 net/hsr/hsr_framereg.c |  9 ++-----
 net/hsr/hsr_netlink.c  | 61 +++++++++++++++++++++++++++---------------
 2 files changed, 41 insertions(+), 29 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw
Quoted 17 lines · Taehee Yoo

This patchset is to fix several bugs they are related in generic netlink callback in hsr module.

1. The first patch is to add missing rcu_read_lock() in hsr_get_node_{list/status}().
The hsr_get_node_{list/status}() are not protected by RTNL because they are callback functions of generic netlink.
But it calls __dev_get_by_index() without acquiring RTNL. So, it would use unsafe data.

2. The second patch is to avoid failure of hsr_get_node_list(). hsr_get_node_list() is a callback of generic netlink and it is used to get node information in userspace.
But, if there are so many nodes, it fails because of buffer size. So, in this patch, restart routine is added.

Quoted 6 lines

3. The third patch is to set .netnsok flag to true.
If .netnsok flag is false, non-init_net namespace is not allowed to operate generic netlink operations.
So, currently, non-init_net namespace has no way to get node information because .netnsok is false in the current hsr code.

I found that the second patch doesn't preserve reverse christmas tree variable ordering.
So, I will send a v2 patch.

Quoted 12 lines

Taehee Yoo (3):
hsr: use rcu_read_lock() in hsr_get_node_{list/status}()
hsr: add restart routine into hsr_get_node_list()
hsr: set .netnsok flag

 net/hsr/hsr_framereg.c |  9 ++-----
 net/hsr/hsr_netlink.c  | 61 +++++++++++++++++++++++++++---------------
 2 files changed, 41 insertions(+), 29 deletions(-)

--
2.17.1