Skip to contentSkip to conversation

net/ethtool/tunnels: check the return value of nla_nest_start()

PATCH Superseded Li Zhong 2 participants 2 messages Sep 21, 2022

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH v2 1/1 net/ethtool/tunnels: check the return value of nla_nest_start()

Check the return value of nla_nest_start(). When starting the entry level nested attributes, if the tailroom of socket buffer is insufficient to store the attribute header and payload, the return value will be NULL and we should check it. If it is NULL, go to the error_cancel_entry label to do error handling.

v2: error handling jump to error_cancel_entry, more details in commit meesage

---
 net/ethtool/tunnels.c | 2 ++
 1 file changed, 2 insertions(+)
net/ethtool/tunnels.c +2 -0
index efde33536687..67fb414ca859 100644
@@ -136,6 +136,8 @@ ethnl_tunnel_info_fill_reply(const struct ethnl_req_info *req_base,
 			goto err_cancel_table;
 
 		entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
+		if (!entry)
+			goto err_cancel_entry;
 
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 htons(IANA_VXLAN_UDP_PORT)) ||
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 1 line · On Wed, 21 Sep 2022 01:30:04 -0700 Li Zhong wrote:

Subject: [PATCH net-next v2] net/ethtool/tunnels: check the return value of nla_nest_start()

Please update the subject to follow the standard kernel convention. The prefix should be something like

ethtool: tunnels:

or just

ethtool:

Quoted 5 lines

Check the return value of nla_nest_start(). When starting the entry level nested attributes, if the tailroom of socket buffer is insufficient to store the attribute header and payload, the return value will be NULL and we should check it. If it is NULL, go to the error_cancel_entry label to do error handling.

Better but don't explain what the patch does but lean more into the assessment of the situation. The last sentence is unnecessary, but you should include an explanation if there is any _actual_ bug here. Can something crash or misbehave?

Quoted 2 lines

v2: error handling jump to error_cancel_entry, more details in commit meesage

This should go under the --- separator