netfilter: avoid array overflow in nf_register_hook
Subsystems (3)
PATCH 1/1 netfilter: avoid array overflow in nf_register_hook
This patch fix the array overflow in nf_register_hook function
Signed-off-by Dong Fang <[email protected]>
--- net/netfilter/core.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
net/netfilter/core.c +4 -1
@@ -68,8 +68,11 @@ static DEFINE_MUTEX(nf_hook_mutex);int nf_register_hook (struct nf_hook_ops *reg) {struct nf_hook_ops *elem; -int err; +int err = -EINVAL ; +if (reg->pf >=NFPROTO_NUMPROTO || reg->hooknum >=NF_MAX_HOOKS ) +return err; + err =mutex_lock_interruptible (&nf_hook_mutex);if (err <0 )return err;
Signature · 1 line
1.7.1
Quoted 12 lines · Dong Fang
This patch fix the array overflow in
nf_register_hookfunctionSigned-off-by Dong Fang <[email protected]>--- net/netfilter/core.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)net/netfilter/core.c +0
-0
net/netfilter/core.c static DEFINE_MUTEX(nf_hook_mutex); · line 75
Quoted 9 lines
net/netfilter/core.c +4
-1@@ -68,8 +68,11 @@ static DEFINE_MUTEX(nf_hook_mutex);int nf_register_hook (struct nf_hook_ops *reg) {struct nf_hook_ops *elem; -int err; +int err = -EINVAL ; +if (reg->pf >=NFPROTO_NUMPROTO || reg->hooknum >=NF_MAX_HOOKS ) +return err; +
Thats a bug in the caller.
We want a hard crash so that the poor netfilter guy who made this error can fix the bug before sending us a buggy patch.