lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 9 Mar 2022 20:50:35 -0700
From:   David Ahern <dsahern@...il.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     davem@...emloft.net, netdev@...r.kernel.org, jiri@...nulli.us,
        George Shuklin <george.shuklin@...il.com>
Subject: Re: [PATCH net-next 2/2] net: limit altnames to 64k total

On 3/9/22 8:37 PM, Jakub Kicinski wrote:
> On Wed, 9 Mar 2022 19:51:07 -0700 David Ahern wrote:
>> On 3/9/22 11:29 AM, Jakub Kicinski wrote:
>>> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>>> index aa05e89cc47c..159c9c61e6af 100644
>>> --- a/net/core/rtnetlink.c
>>> +++ b/net/core/rtnetlink.c
>>> @@ -3652,12 +3652,23 @@ 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;
>>>  
>>> +	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;  
>>
>> this tests the existing property size. Don't you want to test the size
>> with the alt_ifname - does it make the list go over 64kB?
> 
> Do you mean counting the exact length of the string?
> 
> Or that I'm counting pre-add? That's why I added:
> 
> 	size += nla_total_size(ALTIFNAMSIZ);
> 
> I like coding things up as prepare (validate) + commit,
> granted it doesn't exactly look pretty here so I can recode
> if you prefer. But there's no bug, right? (other than maybe 
>> = could have been > but whatever).

right. It's a worst case size estimation versus taking into account the
actual space used for the name (rtnl_prop_list_size does that for each
name so this is really conservative in space use).

Reviewed-by: David Ahern <dsahern@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ