Fixes to network device group configuration via rtnetlink
Subsystems (2)
PATCH 2/3 rtnetlink: fix potential NULL pointer dereference
In reply to Sergey PopovichNow since commit fbdc1e8c6b79 (rtnetlink: walk through all devs in netns safely on link params change) group of network devices can be moved into another network namespace, there is NULL pointer dereference in the do_setlink() as it get's called from rtnl_group_changelink() with ifname == NULL.
--- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/rtnetlink.c +1 -1
@@ -1484,7 +1484,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,* name provided implies that a name change has been * requested. */ -if (ifm->ifi_index >0 && ifname[0 ]) { +if (ifname && ifname[0 ] && ifm->ifi_index >0 ) { err =dev_change_name (dev, ifname);if (err <0 ) goto errout;
Signature · 1 line
1.8.3.4
cover Fixes to network device group configuration via rtnetlink
In this small patch series I present few fixes to the network device group configuration via rtnetlink interface.
For more information on problems addressed, please see description of each patch in the thread.
Sergey Popovich (3):
rtnetlink: walk through all devs in netns safely on link params change
rtnetlink: fix potential NULL pointer dereference
rtnetlink: add IFLA_GROUP to ifla_policy
net/core/rtnetlink.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.4
PATCH 3/3 rtnetlink: add IFLA_GROUP to ifla_policy
Network interface groups support added while ago, however there is no IFLA_GROUP attribute description in policy until now.
Add IFLA_GROUP attribute to the policy.
--- net/core/rtnetlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/rtnetlink.c +2 -0
@@ -823,6 +823,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, +nla_total_size (1 )/* IFLA_OPERSTATE */ +nla_total_size (1 )/* IFLA_LINKMODE */ +nla_total_size (4 )/* IFLA_CARRIER_CHANGES */ + +nla_total_size (4 )/* IFLA_GROUP */ +nla_total_size (ext_filter_mask &RTEXT_FILTER_VF ?4 :0 )/* IFLA_NUM_VF */ +rtnl_vfinfo_size (dev, ext_filter_mask)/* IFLA_VFINFO_LIST */
@@ -1151,6 +1152,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN }, [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */ + [IFLA_GROUP] = { .type = NLA_U32 }, };static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX +1 ] = {
Signature · 1 line
1.8.3.4
PATCH 1/3 rtnetlink: walk through all devs in netns safely on link params change
In reply to Sergey PopovichChanging parameters of group of network interfaces may lead to system hang during change, caused by unsafe walking through list of network interfaces in current network namespace.
This could be easily reproduced with following configuration:
# ip netns add pc10 # ip link add dev dummy128 group 128 type dummy # ip link set group 128 netns pc10
--- net/core/rtnetlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/rtnetlink.c +2 -2
@@ -1782,10 +1782,10 @@ static int rtnl_group_changelink(struct net *net, int group,struct ifinfomsg *ifm, struct nlattr **tb) { - struct net_device *dev; + struct net_device *dev, *aux;int err; -for_each_netdev (net, dev) { +for_each_netdev_safe (net, dev, aux) {if (dev->group == group) { err =do_setlink (dev, ifm, tb,NULL ,0 );if (err <0 )
Signature · 1 line
1.8.3.4
Re: [PATCH 2/3] rtnetlink: fix potential NULL pointer dereference
In reply to Sergey PopovichВ письме от 6 мая 2014 18:13:16 пользователь Sergey Popovich написал:
Quoted 8 lines
Now since commit
fbdc1e8c6b79(rtnetlink: walk through all devs in netns safely on link params change) group of network devices can be moved into another network namespace, there is NULL pointer dereference in thedo_setlink()as it get's called fromrtnl_group_changelink()with ifname == NULL.Fixes e7ed828f10bd netlink: support setting devgroup parametersSigned-off-by Sergey Popovich <[email protected]>
Not needed, self-rejected patch, ifm->ifi_index is == 0 when calling from rtnl_group_changelink().
Sorry for noise.
Quoted 17 lines
--- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/core/rtnetlink.c +0
-0@@ -1484,7 +1484,7 @@ static int do_setlink(struct net_device *dev, structifinfomsg *ifm, * name provided implies that a name change has been
net/core/rtnetlink.c +1
-1* requested. */ -if (ifm->ifi_index >0 && ifname[0 ]) { +if (ifname && ifname[0 ] && ifm->ifi_index >0 ) { err =dev_change_name (dev, ifname);if (err <0 ) goto errout;
Signature · 2 lines
SP5474-RIPE Sergey Popovich
David Miller
maintainerRe: [PATCH 2/3] rtnetlink: fix potential NULL pointer dereference
In reply to Sergey PopovichFrom: Sergey Popovich <[email protected]>
Date: Tue, 6 May 2014 18:13:16 +0300
Quoted 2 lines
Now since commit
fbdc1e8c6b79(rtnetlink: walk through all devs in netns safely on link params change) group of network devices can
This is not how you do this, first of all that SHA ID doesn't exist in any tree other than your's. It's not an existing commit, but rather one you are adding in this series.
And secondly, and even more importantly, your patch in this series is adding this new NULL pointer case.
Therefore you should adjust your first patch to handle this properly since it introduced the possibility of it happening in the first place.