Skip to content

Commit 01acb2e

Browse files
committed
netfilter: nft_chain_filter: handle NETDEV_UNREGISTER for inet/ingress basechain
Remove netdevice from inet/ingress basechain in case NETDEV_UNREGISTER event is reported, otherwise a stale reference to netdevice remains in the hook list. Fixes: 60a3815 ("netfilter: add inet ingress support") Cc: stable@vger.kernel.org Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent b253d87 commit 01acb2e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

net/netfilter/nft_chain_filter.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ static int nf_tables_netdev_event(struct notifier_block *this,
357357
unsigned long event, void *ptr)
358358
{
359359
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
360+
struct nft_base_chain *basechain;
360361
struct nftables_pernet *nft_net;
361-
struct nft_table *table;
362362
struct nft_chain *chain, *nr;
363+
struct nft_table *table;
363364
struct nft_ctx ctx = {
364365
.net = dev_net(dev),
365366
};
@@ -371,7 +372,8 @@ static int nf_tables_netdev_event(struct notifier_block *this,
371372
nft_net = nft_pernet(ctx.net);
372373
mutex_lock(&nft_net->commit_mutex);
373374
list_for_each_entry(table, &nft_net->tables, list) {
374-
if (table->family != NFPROTO_NETDEV)
375+
if (table->family != NFPROTO_NETDEV &&
376+
table->family != NFPROTO_INET)
375377
continue;
376378

377379
ctx.family = table->family;
@@ -380,6 +382,11 @@ static int nf_tables_netdev_event(struct notifier_block *this,
380382
if (!nft_is_base_chain(chain))
381383
continue;
382384

385+
basechain = nft_base_chain(chain);
386+
if (table->family == NFPROTO_INET &&
387+
basechain->ops.hooknum != NF_INET_INGRESS)
388+
continue;
389+
383390
ctx.chain = chain;
384391
nft_netdev_event(event, dev, &ctx);
385392
}

0 commit comments

Comments
 (0)