lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150715190011.GA1203@salvia>
Date:	Wed, 15 Jul 2015 21:00:11 +0200
From:	Pablo Neira Ayuso <pablo@...filter.org>
To:	"Eric W. Biederman" <ebiederm@...ssion.com>
Cc:	netdev@...r.kernel.org, netfilter-devel@...r.kernel.org,
	Stephen Hemminger <stephen@...workplumber.org>,
	Juanjo Ciarlante <jjciarla@...z.uncu.edu.ar>,
	Wensong Zhang <wensong@...ux-vs.org>,
	Simon Horman <horms@...ge.net.au>,
	Julian Anastasov <ja@....bg>,
	Patrick McHardy <kaber@...sh.net>,
	Jozsef Kadlecsik <kadlec@...ckhole.kfki.hu>,
	Jamal Hadi Salim <jhs@...atatu.com>,
	Steffen Klassert <steffen.klassert@...unet.com>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	David Miller <davem@...emloft.net>
Subject: Re: [PATCH -next 5/6] netfilter: Per network namespace netfilter
 hooks.

On Fri, Jul 10, 2015 at 06:15:06PM -0500, Eric W. Biederman wrote:
> @@ -102,13 +112,35 @@ int nf_register_hook(struct nf_hook_ops *reg)
>  #endif
>  	return 0;
>  }
> -EXPORT_SYMBOL(nf_register_hook);
> +EXPORT_SYMBOL(nf_register_net_hook);
>  
> -void nf_unregister_hook(struct nf_hook_ops *reg)
> +void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *reg)
>  {
> +	struct list_head *nf_hook_list;
> +	struct nf_hook_ops *elem;
> +
> +	nf_hook_list = find_nf_hook_list(net, reg);
> +	if (!nf_hook_list)
> +		return;
> +
>  	mutex_lock(&nf_hook_mutex);
> -	list_del_rcu(&reg->list);
> +	list_for_each_entry(elem, nf_hook_list, list) {
> +		if ((reg->hook     == elem->hook) &&
> +		    (reg->dev      == elem->dev) &&
> +		    (reg->owner    == elem->owner) &&
> +		    (reg->priv     == elem->priv) &&
> +		    (reg->pf       == elem->pf) &&
> +		    (reg->hooknum  == elem->hooknum) &&
> +		    (reg->priority == elem->priority)) {
> +			list_del_rcu(&elem->list);
> +			break;
> +		}
> +	}

I think I found a problem with this code above.

If we register two hooks from the same module using exactly the same
tuple that identifies this, we delete the hook that we don't want, eg.

        nft add table filter
        nft add chain filter test { type filter hook input priority 0\; }
        nft add chain filter test2 { type filter hook input priority 0\; }

then, you delete 'test':

        nft delete chain filter test

This will delete 'test2' hook instead of 'test' as it will find this
in first place on the list.

I think we should add a cookie field that stores the address of the
original hook object that is passed as parameter, so we are sure we
kill the right hook.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ