Skip to contentSkip to conversation

netlink: check for null extack in cookie helpers

PATCH Applied Michal Kubecek 2 participants 2 messages Mar 20, 2020 – Mar 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 netlink: check for null extack in cookie helpers

Unlike NL_SET_ERR_* macros, nl_set_extack_cookie_u64() and nl_set_extack_cookie_u32() helpers do not check extack argument for null and neither do their callers, as syzbot recently discovered for ethnl_parse_header().

Instead of fixing the callers and leaving the trap in place, add check of null extack to both helpers to make them consistent with NL_SET_ERR_* macros.

v2: drop incorrect second Fixes tag

Fixes 2363d73a2f3e ("ethtool: reject unrecognized request flags")
Reported-by [email protected]
---
 include/linux/netlink.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/netlink.h +4 -0
index 4090524c3462..60739d0cbf93 100644
@@ -115,6 +115,8 @@ static inline void nl_set_extack_cookie_u64(struct netlink_ext_ack *extack,
 {
 	u64 __cookie = cookie;
 
+	if (!extack)
+		return;
 	memcpy(extack->cookie, &__cookie, sizeof(__cookie));
 	extack->cookie_len = sizeof(__cookie);
 }
@@ -124,6 +126,8 @@ static inline void nl_set_extack_cookie_u32(struct netlink_ext_ack *extack,
 {
 	u32 __cookie = cookie;
 
+	if (!extack)
+		return;
 	memcpy(extack->cookie, &__cookie, sizeof(__cookie));
 	extack->cookie_len = sizeof(__cookie);
 }
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw

From: Michal Kubecek <[email protected]>
Date: Sat, 21 Mar 2020 00:46:50 +0100 (CET)

Quoted 9 lines

Unlike NL_SET_ERR_* macros, nl_set_extack_cookie_u64() and nl_set_extack_cookie_u32() helpers do not check extack argument for null and neither do their callers, as syzbot recently discovered for ethnl_parse_header().

Instead of fixing the callers and leaving the trap in place, add check of null extack to both helpers to make them consistent with NL_SET_ERR_* macros.

Quoted 5 lines

v2: drop incorrect second Fixes tag

Fixes 2363d73a2f3e ("ethtool: reject unrecognized request flags")
Reported-by [email protected]

Applied, thanks Michal.