Commit 46224853 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-control-the-length-of-the-altname-list'

Jakub Kicinski says:

====================
net: control the length of the altname list

Count the memory used for altnames and don't let user
overflow the property nlattr. This was reported by George:
https://lore.kernel.org/all/3e564baf-a1dd-122e-2882-ff143f7eb578@gmail.com/
====================

Link: https://lore.kernel.org/r/20220309182914.423834-1-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 1926407a 155fb43b
......@@ -3652,13 +3652,24 @@ static int rtnl_alt_ifname(int cmd, struct net_device *dev, struct nlattr *attr,
bool *changed, struct netlink_ext_ack *extack)
{
char *alt_ifname;
size_t size;
int err;
err = nla_validate(attr, attr->nla_len, IFLA_MAX, ifla_policy, extack);
if (err)
return err;
alt_ifname = nla_strdup(attr, GFP_KERNEL);
if (cmd == RTM_NEWLINKPROP) {
size = rtnl_prop_list_size(dev);
size += nla_total_size(ALTIFNAMSIZ);
if (size >= U16_MAX) {
NL_SET_ERR_MSG(extack,
"effective property list too long");
return -EINVAL;
}
}
alt_ifname = nla_strdup(attr, GFP_KERNEL_ACCOUNT);
if (!alt_ifname)
return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment