mbox series

[0/2] Add check for nla_nest_start()

Message ID 20221126100634.106887-1-yuancan@huawei.com
Headers show
Series Add check for nla_nest_start() | expand

Message

Yuan Can Nov. 26, 2022, 10:06 a.m. UTC
This series contains two patches about checking the return value of
nla_nest_start().

Yuan Can (2):
  udp_tunnel: Add checks for nla_nest_start() in
    __udp_tunnel_nic_dump_write()
  wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()

 net/ipv4/udp_tunnel_nic.c | 2 ++
 net/wireless/nl80211.c    | 3 +++
 2 files changed, 5 insertions(+)

Comments

David Ahern Nov. 27, 2022, 7:39 p.m. UTC | #1
On 11/26/22 3:06 AM, Yuan Can wrote:
> As the nla_nest_start() may fail with NULL returned, the return value needs
> to be checked.
> 
> Fixes: c7d759eb7b12 ("ethtool: add tunnel info interface")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> ---
>  net/ipv4/udp_tunnel_nic.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
> index bc3a043a5d5c..75a0caa4aebe 100644
> --- a/net/ipv4/udp_tunnel_nic.c
> +++ b/net/ipv4/udp_tunnel_nic.c
> @@ -624,6 +624,8 @@ __udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table,
>  			continue;
>  
>  		nest = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
> +		if (!nest)
> +			goto err_cancel;

no need to call nla_nest_cancel if nest_start fails.

>  
>  		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
>  				 utn->entries[table][j].port) ||
Jakub Kicinski Nov. 28, 2022, 10:18 p.m. UTC | #2
On Sat, 26 Nov 2022 10:06:32 +0000 Yuan Can wrote:
>   udp_tunnel: Add checks for nla_nest_start() in
>     __udp_tunnel_nic_dump_write()
>   wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()

Please post these separately (with David's feedback addressed)
they need to go to different trees so making them as series is
counter-productive.
Yuan Can Nov. 29, 2022, 1:29 a.m. UTC | #3
在 2022/11/28 3:39, David Ahern 写道:
> On 11/26/22 3:06 AM, Yuan Can wrote:
>> As the nla_nest_start() may fail with NULL returned, the return value needs
>> to be checked.
>>
>> Fixes: c7d759eb7b12 ("ethtool: add tunnel info interface")
>> Signed-off-by: Yuan Can <yuancan@huawei.com>
>> ---
>>   net/ipv4/udp_tunnel_nic.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
>> index bc3a043a5d5c..75a0caa4aebe 100644
>> --- a/net/ipv4/udp_tunnel_nic.c
>> +++ b/net/ipv4/udp_tunnel_nic.c
>> @@ -624,6 +624,8 @@ __udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table,
>>   			continue;
>>   
>>   		nest = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
>> +		if (!nest)
>> +			goto err_cancel;
> no need to call nla_nest_cancel if nest_start fails.
Ok, thanks for the suggestion, it will be fixed in the next version.
Yuan Can Nov. 29, 2022, 1:30 a.m. UTC | #4
在 2022/11/29 6:18, Jakub Kicinski 写道:
> On Sat, 26 Nov 2022 10:06:32 +0000 Yuan Can wrote:
>>    udp_tunnel: Add checks for nla_nest_start() in
>>      __udp_tunnel_nic_dump_write()
>>    wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()
> Please post these separately (with David's feedback addressed)
> they need to go to different trees so making them as series is
> counter-productive.
Ok, thanks for the suggestion!