monitor: missing cache and set handle initialization
Pablo Neira Ayuso
maintainerPATCH 1/1 monitor: missing cache and set handle initialization
This leads to a crash when adding stateful expressions to sets:
netlink.c:928:38: runtime error: member access within null pointer of type 'struct nft_ctx' AddressSanitizer:DEADLYSIGNAL
=================================================================
==13781==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000d0 (pc 0x7fc96fc2b6b2 bp 0x7ffc0e26b080 sp 0x7ffc0e26b020 T0) ==13781==The signal is caused by a READ memory access.
==13781==Hint: address points to the zero page.
#0 0x7fc96fc2b6b2 in table_cache_find /home/pablo/devel/scm/git-netfilter/nftables/src/cache.c:456
#1 0x7fc96fd244d4 in netlink_parse_set_expr /home/pablo/devel/scm/git-netfilter/nftables/src/netlink_delinearize.c:1857
#2 0x7fc96fcf1b4d in netlink_delinearize_set /home/pablo/devel/scm/git-netfilter/nftables/src/netlink.c:928
#3 0x7fc96fd41966 in netlink_events_cache_addset /home/pablo/devel/scm/git-netfilter/nftables/src/monitor.c:649Signed-off-by Pablo Neira Ayuso <[email protected]>
--- src/monitor.c | 2 ++ tests/monitor/testcases/map-expr.t | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 tests/monitor/testcases/map-expr.t
src/monitor.c +2 -0
@@ -428,6 +428,7 @@ static int netlink_events_setelem_cb(const struct nlmsghdr *nlh, int type,* used by named sets, so use a dummy set. */ dummyset =set_alloc (monh->loc); +handle_merge (&dummyset->handle, &set->handle); dummyset->key =expr_clone (set->key);if (set->data) dummyset->data =expr_clone (set->data);
@@ -643,6 +644,7 @@ static void netlink_events_cache_addset(struct netlink_mon_handler *monh,memset (&set_tmpctx,0 ,sizeof (set_tmpctx));init_list_head (&set_tmpctx.list);init_list_head (&msgs); + set_tmpctx.nft = monh->ctx->nft; set_tmpctx.msgs = &msgs; nls =netlink_set_alloc (nlh);
tests/monitor/testcases/map-expr.t new file +6 -0
@@ -0,0 +1,6 @@ +# first the setup +I add table ip t +I add map ip t m { typeof meta day . meta hour : verdict; flags interval; counter; } +O - +J {"add": {"table": {"family": "ip", "name": "t", "handle": 0}}} +J {"add": {"map": {"family": "ip", "name": "m", "table": "t", "type": ["day", "hour"], "handle": 0, "map": "verdict", "flags": ["interval"], "stmt": [{"counter": null}]}}}
Signature · 1 line
2.30.2