netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add check for nla_nest_start()
@ 2022-11-26 10:06 Yuan Can
  2022-11-26 10:06 ` [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write() Yuan Can
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yuan Can @ 2022-11-26 10:06 UTC (permalink / raw)
  To: johannes, davem, yoshfuji, dsahern, edumazet, kuba, pabeni,
	linux-wireless, netdev
  Cc: yuancan

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(+)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write()
  2022-11-26 10:06 [PATCH 0/2] Add check for nla_nest_start() Yuan Can
@ 2022-11-26 10:06 ` Yuan Can
  2022-11-27 19:39   ` David Ahern
  2022-11-26 10:06 ` [PATCH 2/2] wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface() Yuan Can
  2022-11-28 22:18 ` [PATCH 0/2] Add check for nla_nest_start() Jakub Kicinski
  2 siblings, 1 reply; 7+ messages in thread
From: Yuan Can @ 2022-11-26 10:06 UTC (permalink / raw)
  To: johannes, davem, yoshfuji, dsahern, edumazet, kuba, pabeni,
	linux-wireless, netdev
  Cc: yuancan

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;
 
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 utn->entries[table][j].port) ||
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()
  2022-11-26 10:06 [PATCH 0/2] Add check for nla_nest_start() Yuan Can
  2022-11-26 10:06 ` [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write() Yuan Can
@ 2022-11-26 10:06 ` Yuan Can
  2022-11-28 22:18 ` [PATCH 0/2] Add check for nla_nest_start() Jakub Kicinski
  2 siblings, 0 replies; 7+ messages in thread
From: Yuan Can @ 2022-11-26 10:06 UTC (permalink / raw)
  To: johannes, davem, yoshfuji, dsahern, edumazet, kuba, pabeni,
	linux-wireless, netdev
  Cc: yuancan

As the nla_nest_start() may fail with NULL returned, the return value needs
to be checked.

Fixes: ce08cd344a00 ("wifi: nl80211: expose link information for interfaces")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 net/wireless/nl80211.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 597c52236514..d2321c683398 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3868,6 +3868,9 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
 			struct cfg80211_chan_def chandef = {};
 			int ret;
 
+			if (!link)
+				goto nla_put_failure;
+
 			if (nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, link_id))
 				goto nla_put_failure;
 			if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write()
  2022-11-26 10:06 ` [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write() Yuan Can
@ 2022-11-27 19:39   ` David Ahern
  2022-11-29  1:29     ` Yuan Can
  0 siblings, 1 reply; 7+ messages in thread
From: David Ahern @ 2022-11-27 19:39 UTC (permalink / raw)
  To: Yuan Can, johannes, davem, yoshfuji, edumazet, kuba, pabeni,
	linux-wireless, netdev

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) ||


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] Add check for nla_nest_start()
  2022-11-26 10:06 [PATCH 0/2] Add check for nla_nest_start() Yuan Can
  2022-11-26 10:06 ` [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write() Yuan Can
  2022-11-26 10:06 ` [PATCH 2/2] wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface() Yuan Can
@ 2022-11-28 22:18 ` Jakub Kicinski
  2022-11-29  1:30   ` Yuan Can
  2 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2022-11-28 22:18 UTC (permalink / raw)
  To: Yuan Can
  Cc: johannes, davem, yoshfuji, dsahern, edumazet, pabeni,
	linux-wireless, netdev

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write()
  2022-11-27 19:39   ` David Ahern
@ 2022-11-29  1:29     ` Yuan Can
  0 siblings, 0 replies; 7+ messages in thread
From: Yuan Can @ 2022-11-29  1:29 UTC (permalink / raw)
  To: David Ahern, johannes, davem, yoshfuji, edumazet, kuba, pabeni,
	linux-wireless, netdev


在 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.

-- 
Best regards,
Yuan Can


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] Add check for nla_nest_start()
  2022-11-28 22:18 ` [PATCH 0/2] Add check for nla_nest_start() Jakub Kicinski
@ 2022-11-29  1:30   ` Yuan Can
  0 siblings, 0 replies; 7+ messages in thread
From: Yuan Can @ 2022-11-29  1:30 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: johannes, davem, yoshfuji, dsahern, edumazet, pabeni,
	linux-wireless, netdev


在 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!

-- 
Best regards,
Yuan Can


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-29  1:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-26 10:06 [PATCH 0/2] Add check for nla_nest_start() Yuan Can
2022-11-26 10:06 ` [PATCH 1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write() Yuan Can
2022-11-27 19:39   ` David Ahern
2022-11-29  1:29     ` Yuan Can
2022-11-26 10:06 ` [PATCH 2/2] wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface() Yuan Can
2022-11-28 22:18 ` [PATCH 0/2] Add check for nla_nest_start() Jakub Kicinski
2022-11-29  1:30   ` Yuan Can

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).