rtnetlink: call validate_linkmsg in rtnl_create_link
authorXin Long <lucien.xin@gmail.com>
Wed, 31 May 2023 16:01:42 +0000 (12:01 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jun 2023 08:34:05 +0000 (10:34 +0200)
commitea9d7382d5d3cbb733b71cad829a4299bc348b2d
tree3ea41e017b6fd35af453ee87006c512e08e32cc1
parent62dcac528be74d62024d38e04524d6c824d61896
rtnetlink: call validate_linkmsg in rtnl_create_link

commit b0ad3c179059089d809b477a1d445c1183a7b8fe upstream.

validate_linkmsg() was introduced by commit 1840bb13c22f5b ("[RTNL]:
Validate hardware and broadcast address attribute for RTM_NEWLINK")
to validate tb[IFLA_ADDRESS/BROADCAST] for existing links. The same
check should also be done for newly created links.

This patch adds validate_linkmsg() call in rtnl_create_link(), to
avoid the invalid address set when creating some devices like:

  # ip link add dummy0 type dummy
  # ip link add link dummy0 name mac0 address 01:02 type macsec

Fixes: 0e06877c6fdb ("[RTNETLINK]: rtnl_link: allow specifying initial device address")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/rtnetlink.c