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
Hello.
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 74
Quoted 8 lines
net/netfilter/core.c +3
-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;
Why not just return -EINVAL and avoid unneeded 'err' initialization?
net/netfilter/core.c static DEFINE_MUTEX(nf_hook_mutex); · line 78
Quoted 4 lines
net/netfilter/core.c +1
-0+ err =mutex_lock_interruptible (&nf_hook_mutex);if (err <0 )return err;
WBR, Sergei