All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Giuseppe Longo <giuseppelng@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] nftables: fix length of set name
Date: Mon, 24 Mar 2014 15:57:05 +0100	[thread overview]
Message-ID: <20140324145704.GA32472@localhost> (raw)
In-Reply-To: <1395423541-5098-2-git-send-email-giuseppelng@gmail.com>

On Fri, Mar 21, 2014 at 06:39:01PM +0100, Giuseppe Longo wrote:
> This patch permits to copy the last char of the set name
> that's currently excluded.
> 
> nft add table ip test
> nft add chain ip test filter {type filter hook input priority 0 \; }
> nft add set ip test thisnamewith0016 { type ipv4_address\;}
> nft list table ip test
> table ip test {
>         set thisnamewith0016 {
>                 type ipv4_address
>         }
> 
>         chain filter {
>                  type filter hook input priority 0;
>         }
> }
> 
> Signed-off-by: Giuseppe Longo <giuseppelng@gmail.com>
> ---
>  net/netfilter/nf_tables_api.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index adce01e..a0da542 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -2018,7 +2018,7 @@ static int nf_tables_set_alloc_name(struct nft_ctx *ctx, struct nft_set *set,
>  		free_page((unsigned long)inuse);
>  	}
>  
> -	snprintf(set->name, sizeof(set->name), name, n);
> +	snprintf(set->name, sizeof(set->name)+1, name, n);

This allows to write up to 16+1 bytes.

>  	list_for_each_entry(i, &ctx->table->sets, list) {
>  		if (!strcmp(set->name, i->name))
>  			return -ENFILE;
> @@ -2399,7 +2399,7 @@ static int nf_tables_newset(struct sock *nlsk, struct sk_buff *skb,
>  	if (set == NULL)
>  		goto err1;
>  
> -	nla_strlcpy(name, nla[NFTA_SET_NAME], sizeof(set->name));
> +	nla_strlcpy(name, nla[NFTA_SET_NAME], sizeof(set->name)+1);

Same thing here, but the name size is just 16 bytes long.

  reply	other threads:[~2014-03-24 14:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-21 17:39 [nft PATCH] src: check if the set name is too long Giuseppe Longo
2014-03-21 17:39 ` [PATCH] nftables: fix length of set name Giuseppe Longo
2014-03-24 14:57   ` Pablo Neira Ayuso [this message]
2014-03-24 14:57 ` [nft PATCH] src: check if the set name is too long Pablo Neira Ayuso
2014-03-25  7:37   ` Tomasz Bursztyka
2014-03-25  8:41     ` Pablo Neira Ayuso
2014-03-25  8:47       ` 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=20140324145704.GA32472@localhost \
    --to=pablo@netfilter.org \
    --cc=giuseppelng@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.