Skip to content

Commit

Permalink
netfilter: Only allow sane values in nf_register_net_hook
Browse files Browse the repository at this point in the history
This commit adds an upfront check for sane values to be passed when
registering a netfilter hook.  This will be used in a future patch for a
simplified hook list traversal.

Signed-off-by: Aaron Conole <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
apconole authored and ummakynes committed Sep 24, 2016
1 parent e2361cb commit d4bb5ca
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/netfilter/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg)
struct nf_hook_entry *entry;
struct nf_hook_ops *elem;

if (reg->pf == NFPROTO_NETDEV &&
(reg->hooknum != NF_NETDEV_INGRESS ||
!reg->dev || dev_net(reg->dev) != net))
return -EINVAL;

entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (!entry)
return -ENOMEM;
Expand Down

0 comments on commit d4bb5ca

Please sign in to comment.