netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>,
	netfilter-devel@vger.kernel.org, kaber@trash.net, tgraf@suug.ch
Subject: Re: [PATCH 3/3] netfilter: nf_tables: enforce NLA_NUL_STRING in strings
Date: Mon, 31 Mar 2014 15:08:25 +0200	[thread overview]
Message-ID: <20140331130825.GD4682@breakpoint.cc> (raw)
In-Reply-To: <20140331124600.GA4335@localhost>

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> I think you're right, a quick look at the users of this:
> 
> net/core/fib_rules.c:               nla_strcmp(tb[FRA_IIFNAME], rule->iifname))
> net/core/fib_rules.c:               nla_strcmp(tb[FRA_OIFNAME], rule->oifname))
> net/core/neighbour.c:           if (nla_strcmp(tb[NDTA_NAME], tbl->id) == 0)
> net/decnet/dn_dev.c:            if (tb[IFA_LABEL] && nla_strcmp(tb[IFA_LABEL], ifa->ifa_label))
> net/ipv4/devinet.c:             if (tb[IFA_LABEL] && nla_strcmp(tb[IFA_LABEL], ifa->ifa_label))
> net/netfilter/nf_tables_api.c:          if (!nla_strcmp(nla, table->name))
> net/netfilter/nf_tables_api.c:              !nla_strcmp(nla, chain_type[family][i]->name))
> net/netfilter/nf_tables_api.c:          if (!nla_strcmp(nla, chain->name))
> net/netfilter/nf_tables_api.c:          if (!nla_strcmp(nla, type->name) &&
> net/netfilter/nf_tables_api.c:          if (!nla_strcmp(nla, set->name))
> net/sched/act_api.c:                    if (nla_strcmp(kind, a->kind) == 0) {
> net/sched/cls_api.c:                    if (nla_strcmp(kind, t->kind) == 0) {
> net/sched/cls_api.c:    } else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind))
> net/sched/sch_api.c:                    if (nla_strcmp(kind, q->id) == 0) {
> net/sched/sch_api.c:    if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id))
> net/sched/sch_api.c:                            if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id))
> net/sched/sch_api.c: nla_strcmp(tca[TCA_KIND], q->ops->id))))
> net/sched/sch_api.c:    if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id
> 
> In the current iproute2 tree: /ip/ipntable.c:
> 
>         len = strlen(namep) + 1;
>         addattr_l(&req.n, sizeof(req), NDTA_NAME, namep, len)
> 
> from ip/ipaddress.c:
> 
> addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l)+1)
> 
> They are indeed including the nul-termination, that's why the
> comparison is working.
> I don't find any validation for TCA_KIND though, but that nla_strcmp
> is implicitly enforcing the nul-termination, otherwise will return a
> mismatch.

You're right, aliasing it to nla_memcmp would break iproute2.

So looks like we'd have to add backwards compat to nla_strcmp and check if the last
byte of nla data is a zero byte to catch this.

Lets see if Thomas has a better idea.

  reply	other threads:[~2014-03-31 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-31 11:51 [PATCH 1/3] netfilter: nf_tables: set names cannot be larger than 15 bytes Pablo Neira Ayuso
2014-03-31 11:51 ` [PATCH 2/3] netfilter: nf_tables: fix wrong format in request_module() Pablo Neira Ayuso
2014-03-31 11:51 ` [PATCH 3/3] netfilter: nf_tables: enforce NLA_NUL_STRING in strings Pablo Neira Ayuso
2014-03-31 12:15   ` Florian Westphal
2014-03-31 12:46     ` Pablo Neira Ayuso
2014-03-31 13:08       ` Florian Westphal [this message]
2014-03-31 14:09         ` Thomas Graf

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=20140331130825.GD4682@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=tgraf@suug.ch \
    /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).