From: Thomas Haller <thaller@redhat.com>
To: Michal Kubecek <mkubecek@suse.cz>,
"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Johannes Berg <johannes@sipsolutions.net>,
David Ahern <dsahern@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 3/3] netlink: add validation of NLA_F_NESTED flag
Date: Tue, 23 Jul 2019 10:57:54 +0200 [thread overview]
Message-ID: <0fc58a4883f6656208b9250876e53d723919e342.camel@redhat.com> (raw)
In-Reply-To: <6b6ead21c5d8436470b82ab40355f6bd7dbbf14b.1556806084.git.mkubecek@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 1628 bytes --]
On Thu, 2019-05-02 at 16:15 +0200, Michal Kubecek wrote:
> Add new validation flag NL_VALIDATE_NESTED which adds three
> consistency
> checks of NLA_F_NESTED_FLAG:
>
> - the flag is set on attributes with NLA_NESTED{,_ARRAY} policy
> - the flag is not set on attributes with other policies except
> NLA_UNSPEC
> - the flag is set on attribute passed to nla_parse_nested()
>
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
>
> v2: change error messages to mention NLA_F_NESTED explicitly
> ---
> include/net/netlink.h | 11 ++++++++++-
> lib/nlattr.c | 15 +++++++++++++++
> 2 files changed, 25 insertions(+), 1 deletion(-)
Hi,
libnl3 does currently not ever set NLA_F_NESTED flag.
That means, nla_nest_start() will not work as it used to.
https://github.com/thom311/libnl/blob/65b3dd5ac2d5de4c7a0c64e430596d9d27973527/lib/attr.c#L902
As workaround, one could call
nla_nest_start(msg, NLA_F_NESTED | attr);
Of course, that is a bug in libnl3 that should be fixed. But it seems
quite unfortunate to me.
Does this flag and strict validation really provide any value? Commonly a netlink message
is a plain TLV blob, and the meaning depends entirely on the policy.
What I mean is that for example
NLA_PUT_U32 (msg, ATTR_IFINDEX, (uint32_t) ifindex)
NLA_PUT_STRING (msg, ATTR_IFNAME, "net")
results in a 4 bytes payload that does not encode whether the data is a number or
a string.
Why is it valuable in this case to encode additional type information inside the message,
when it's commonly not done and also not necessary?
best,
Thomas
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-07-23 8:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 14:15 [PATCH net-next v2 0/3] netlink: strict attribute checking follow-up Michal Kubecek
2019-05-02 14:15 ` [PATCH net-next v2 1/3] genetlink: do not validate dump requests if there is no policy Michal Kubecek
2019-05-02 14:15 ` [PATCH net-next v2 2/3] netlink: set bad attribute also on maxtype check Michal Kubecek
2019-05-02 14:15 ` [PATCH net-next v2 3/3] netlink: add validation of NLA_F_NESTED flag Michal Kubecek
2019-05-02 15:30 ` Johannes Berg
2019-05-02 22:56 ` David Ahern
2019-07-23 8:57 ` Thomas Haller [this message]
2019-07-23 9:09 ` Michal Kubecek
2019-07-23 9:28 ` Thomas Haller
2019-07-25 2:46 ` David Ahern
2019-07-23 18:02 ` Stephen Hemminger
2019-07-23 18:17 ` Johannes Berg
2019-05-04 5:27 ` [PATCH net-next v2 0/3] netlink: strict attribute checking follow-up David Miller
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=0fc58a4883f6656208b9250876e53d723919e342.camel@redhat.com \
--to=thaller@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@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).