From: Pablo Neira Ayuso <pablo@netfilter.org>
To: fgao@ikuai8.com
Cc: kaber@trash.net, davem@davemloft.net,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, gfree.wind@gmail.com
Subject: Re: [PATCH nf-next] netfilter: log: Check param to avoid overflow in nf_log_set
Date: Mon, 29 Aug 2016 11:55:25 +0200 [thread overview]
Message-ID: <20160829095525.GB2407@salvia> (raw)
In-Reply-To: <1472394618-5711-1-git-send-email-fgao@ikuai8.com>
On Sun, Aug 28, 2016 at 10:30:18PM +0800, fgao@ikuai8.com wrote:
> 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;
I'd suggest you change this function nf_log_set() to:
int nf_log_set(struct net *net, ...)
And update the callsites.
Then, you can simply return -EOPNOTSUPP instead and remove that
pr_err() message. This message is very unlikely to be displayed.
Thanks!
prev parent reply other threads:[~2016-08-29 9:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=20160829095525.GB2407@salvia \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=fgao@ikuai8.com \
--cc=gfree.wind@gmail.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).