From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Dong Fang <yp.fangdong@gmail.com>
Cc: pablo@netfilter.org, kaber@trash.net, kadlec@blackhole.kfki.hu,
davem@davemloft.net, netfilter-devel@vger.kernel.org,
netfilter@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org
Subject: Re: [PATCH] netfilter: avoid array overflow in nf_register_hook
Date: Fri, 23 Aug 2013 22:14:39 +0400 [thread overview]
Message-ID: <5217A68F.2050302@cogentembedded.com> (raw)
In-Reply-To: <1377313651-16096-1-git-send-email-yp.fangdong@gmail.com>
Hello.
On 08/24/2013 07:07 AM, Dong Fang wrote:
> This patch fix the array overflow in nf_register_hook function
> Signed-off-by: Dong Fang <yp.fangdong@gmail.com>
> ---
> net/netfilter/core.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
> diff --git a/net/netfilter/core.c b/net/netfilter/core.c
> index 2217363..819eee1 100644
> --- a/net/netfilter/core.c
> +++ b/net/netfilter/core.c
> @@ -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?
> +
> err = mutex_lock_interruptible(&nf_hook_mutex);
> if (err < 0)
> return err;
WBR, Sergei
next prev parent reply other threads:[~2013-08-23 18:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-24 3:07 [PATCH] netfilter: avoid array overflow in nf_register_hook Dong Fang
2013-08-23 18:14 ` Sergei Shtylyov [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-08-24 3:04 Dong Fang
2013-08-23 16:05 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5217A68F.2050302@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=kadlec@blackhole.kfki.hu \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=yp.fangdong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).