diff mbox series

[v2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write()

Message ID 20221129013934.55184-1-yuancan@huawei.com (mailing list archive)
State Accepted
Commit 7a945ce0c19bbdf821d5f7ce1515e7fb8e444465
Delegated to: Netdev Maintainers
Headers show
Series [v2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yuan Can Nov. 29, 2022, 1:39 a.m. UTC
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>
---
Changes in v2:
- return directly without calling nla_nest_cancel if nest_start fails

 net/ipv4/udp_tunnel_nic.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Ahern Nov. 29, 2022, 3:09 a.m. UTC | #1
On 11/28/22 6:39 PM, 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>
> ---
> Changes in v2:
> - return directly without calling nla_nest_cancel if nest_start fails
> 
>  net/ipv4/udp_tunnel_nic.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>
Jakub Kicinski Nov. 29, 2022, 4:50 p.m. UTC | #2
On Mon, 28 Nov 2022 20:09:52 -0700 David Ahern wrote:
> On 11/28/22 6:39 PM, 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>
> 
> Reviewed-by: David Ahern <dsahern@kernel.org>
 
Applying to net-next without the Fixes tag, FWIW. The next put will
fail and we'll bail all the same, this patch is pretty much a noop. 
But not the first "fix" like this we go so probably not point fighting
it.

Yuan, please try to find some other error checking to run your bots on,
I doubt any of the nla_nest_start() uses actually need error checking.
patchwork-bot+netdevbpf@kernel.org Nov. 29, 2022, 5 p.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 29 Nov 2022 01:39:34 +0000 you 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>
> ---
> Changes in v2:
> - return directly without calling nla_nest_cancel if nest_start fails
> 
> [...]

Here is the summary with links:
  - [v2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write()
    https://git.kernel.org/netdev/net-next/c/7a945ce0c19b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
index bc3a043a5d5c..029219749785 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)
+			return -EMSGSIZE;
 
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 utn->entries[table][j].port) ||