Skip to content

Commit 1c4561d

Browse files
kuba-moogregkh
authored andcommitted
net: limit altnames to 64k total
[ Upstream commit 155fb43 ] Property list (altname is a link "property") is wrapped in a nlattr. nlattrs length is 16bit so practically speaking the list of properties can't be longer than that, otherwise user space would have to interpret broken netlink messages. Prevent the problem from occurring by checking the length of the property list before adding new entries. Reported-by: George Shuklin <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 601f748 commit 1c4561d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

net/core/rtnetlink.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,12 +3631,23 @@ static int rtnl_alt_ifname(int cmd, struct net_device *dev, struct nlattr *attr,
36313631
bool *changed, struct netlink_ext_ack *extack)
36323632
{
36333633
char *alt_ifname;
3634+
size_t size;
36343635
int err;
36353636

36363637
err = nla_validate(attr, attr->nla_len, IFLA_MAX, ifla_policy, extack);
36373638
if (err)
36383639
return err;
36393640

3641+
if (cmd == RTM_NEWLINKPROP) {
3642+
size = rtnl_prop_list_size(dev);
3643+
size += nla_total_size(ALTIFNAMSIZ);
3644+
if (size >= U16_MAX) {
3645+
NL_SET_ERR_MSG(extack,
3646+
"effective property list too long");
3647+
return -EINVAL;
3648+
}
3649+
}
3650+
36403651
alt_ifname = nla_strdup(attr, GFP_KERNEL_ACCOUNT);
36413652
if (!alt_ifname)
36423653
return -ENOMEM;

0 commit comments

Comments
 (0)