netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next] netfilter: log: Check param to avoid overflow in nf_log_set
@ 2016-08-28 14:30 fgao
  2016-08-28 22:36 ` Feng Gao
  2016-08-29  9:55 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: fgao @ 2016-08-28 14:30 UTC (permalink / raw)
  To: pablo, kaber, davem, netfilter-devel, coreteam, netdev
  Cc: gfree.wind, Gao Feng

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-29  9:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-28 14:30 [PATCH nf-next] netfilter: log: Check param to avoid overflow in nf_log_set fgao
2016-08-28 22:36 ` Feng Gao
2016-08-29  9:55 ` Pablo Neira Ayuso

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).