From: David Miller <davem@davemloft.net>
To: pablo@netfilter.org
Cc: netdev@vger.kernel.org, fw@strlen.de, tgraf@suug.ch
Subject: Re: [PATCH v2] netlink: don't compare the nul-termination in nla_strcmp
Date: Tue, 01 Apr 2014 15:26:06 -0400 (EDT) [thread overview]
Message-ID: <20140401.152606.1113760851598806005.davem@davemloft.net> (raw)
In-Reply-To: <1396373924-9538-1-git-send-email-pablo@netfilter.org>
From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Tue, 1 Apr 2014 19:38:44 +0200
> From: Pablo Neira <pablo@netfilter.org>
>
> nla_strcmp compares the string length plus one, so it's implicitly
> including the nul-termination in the comparison.
>
> int nla_strcmp(const struct nlattr *nla, const char *str)
> {
> int len = strlen(str) + 1;
> ...
> d = memcmp(nla_data(nla), str, len);
>
> However, if NLA_STRING is used, userspace can send us a string without
> the nul-termination. This is a problem since the string
> comparison will not match as the last byte may be not the
> nul-termination.
>
> Fix this by skipping the comparison of the nul-termination if the
> attribute data is nul-terminated. Suggested by Thomas Graf.
>
> Cc: Florian Westphal <fw@strlen.de>
> Cc: Thomas Graf <tgraf@suug.ch>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Applied and queued up for -stable, thanks Pablo.
prev parent reply other threads:[~2014-04-01 19:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 17:38 [PATCH v2] netlink: don't compare the nul-termination in nla_strcmp Pablo Neira Ayuso
2014-04-01 19:26 ` David Miller [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=20140401.152606.1113760851598806005.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=netdev@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).