From: Liping Zhang <zlpnobody@xxxxxxxxx> Unlike other set types, we will not link struct nft_set_ext into our internal structure, so we need to free it after activation, otherwise the nft_set_ext's memory will be leaked forever. Also move nf_tables_setelem_notify() to the front of ops->activate, so we will not hit the use after free error. Fixes: 665153ff5752 ("netfilter: nf_tables: add bitmap set type") Signed-off-by: Liping Zhang <zlpnobody@xxxxxxxxx> --- net/netfilter/nf_tables_api.c | 2 +- net/netfilter/nft_set_bitmap.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 5e0ccfd..5b949e0 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4809,10 +4809,10 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) case NFT_MSG_NEWSETELEM: te = (struct nft_trans_elem *)trans->data; - te->set->ops->activate(net, te->set, &te->elem); nf_tables_setelem_notify(&trans->ctx, te->set, &te->elem, NFT_MSG_NEWSETELEM, 0); + te->set->ops->activate(net, te->set, &te->elem); nft_trans_destroy(trans); break; case NFT_MSG_DELSETELEM: diff --git a/net/netfilter/nft_set_bitmap.c b/net/netfilter/nft_set_bitmap.c index 9b024e2..dfaf299 100644 --- a/net/netfilter/nft_set_bitmap.c +++ b/net/netfilter/nft_set_bitmap.c @@ -127,6 +127,11 @@ static void nft_bitmap_activate(const struct net *net, nft_bitmap_location(set, nft_set_ext_key(ext), &idx, &off); /* Enter 11 state. */ priv->bitmap[idx] |= (genmask << off); + + /* After the element is active in the bitmap, the dummy extension + * object is not used anymore, free it now. + */ + nft_set_elem_destroy(set, ext, true); } static bool nft_bitmap_flush(const struct net *net, -- 2.5.5 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html