net/ethtool/tunnels: check the return value of nla_nest_start()
Subsystems (3)
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
@@ -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
Jakub Kicinski
maintainerQuoted 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 ofnla_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 theerror_cancel_entrylabel 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