public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: fgao@ikuai8.com
To: pablo@netfilter.org, kaber@trash.net, davem@davemloft.net,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org
Cc: gfree.wind@gmail.com, Gao Feng <fgao@ikuai8.com>
Subject: [PATCH nf-next] netfilter: log: Check param to avoid overflow in nf_log_set
Date: Sun, 28 Aug 2016 22:30:18 +0800	[thread overview]
Message-ID: <1472394618-5711-1-git-send-email-fgao@ikuai8.com> (raw)

From: Gao Feng <fgao@ikuai8.com>

The nf_log_set is an interface function, so it should do the strict sanity
check of parameters. Add  one sanity check for pf, it could not exceed
NFPROTO_NUMPROTO, and print error log when pf is invalid.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
 net/netfilter/nf_log.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index aa5847a..02ce0b9 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -43,8 +43,10 @@ void nf_log_set(struct net *net, u_int8_t pf, const struct nf_logger *logger)
 {
 	const struct nf_logger *log;
 
-	if (pf == NFPROTO_UNSPEC)
+	if (pf == NFPROTO_UNSPEC || pf >= NFPROTO_NUMPROTO) {
+		pr_err("Wrong pf(%d) for nf log", pf);
 		return;
+	}
 
 	mutex_lock(&nf_log_mutex);
 	log = nft_log_dereference(net->nf.nf_loggers[pf]);
-- 
1.9.1

             reply	other threads:[~2016-08-28 14:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28 14:30 fgao [this message]
2016-08-28 22:36 ` [PATCH nf-next] netfilter: log: Check param to avoid overflow in nf_log_set Feng Gao
2016-08-29  9:55 ` Pablo Neira Ayuso

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=1472394618-5711-1-git-send-email-fgao@ikuai8.com \
    --to=fgao@ikuai8.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=gfree.wind@gmail.com \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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