Skip to contentSkip to conversation

src: netlink: fix crash when ops doesn't support udata

PATCH In review Florian Westphal 2 participants 2 messages May 8, 2025 – May 9, 2025 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 src: netlink: fix crash when ops doesn't support udata

Whenever a new version adds udata support to an expression, then old versions of nft will crash when trying to list such a ruleset generated by a more recent version of nftables.

Fix this by falling back to 'type' format.

---
 src/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/netlink.c +1 -1
index 25ee3419772b..5825a68d03bc 100644
@@ -913,7 +913,7 @@ static struct expr *set_make_key(const struct nftnl_udata *attr)
 
 	etype = nftnl_udata_get_u32(ud[NFTNL_UDATA_SET_TYPEOF_EXPR]);
 	ops = expr_ops_by_type_u32(etype);
-	if (!ops)
+	if (!ops || !ops->parse_udata)
 		return NULL;
 
 	expr = ops->parse_udata(ud[NFTNL_UDATA_SET_TYPEOF_DATA]);
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Florian Westphal

Whenever a new version adds udata support to an expression, then old versions of nft will crash when trying to list such a ruleset generated by a more recent version of nftables.

Fix this by falling back to 'type' format.

Fixes 6e48df5329ea ('src: add "typeof" build/parse/print support')
Quoted 1 line

Thanks.

Quoted 21 lines
---
 src/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/netlink.c +1 -1
index 25ee3419772b..5825a68d03bc 100644
@@ -913,7 +913,7 @@ static struct expr *set_make_key(const struct nftnl_udata *attr)
 
 	etype = nftnl_udata_get_u32(ud[NFTNL_UDATA_SET_TYPEOF_EXPR]);
 	ops = expr_ops_by_type_u32(etype);
-	if (!ops)
+	if (!ops || !ops->parse_udata)
 		return NULL;
 
 	expr = ops->parse_udata(ud[NFTNL_UDATA_SET_TYPEOF_DATA]);
Signature · 1 line
2.49.0