From: Johannes Berg <johannes@sipsolutions.net>
To: David Miller <davem@davemloft.net>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, mkubecek@suse.cz
Subject: Re: [RFC v2 1/2] netlink: add NLA_REJECT policy type
Date: Wed, 12 Sep 2018 20:34:45 +0200 [thread overview]
Message-ID: <1536777285.3678.28.camel@sipsolutions.net> (raw)
In-Reply-To: <20180912.111555.1317690378514849083.davem@davemloft.net>
On Wed, 2018-09-12 at 11:15 -0700, David Miller wrote:
> This looks great, no objections to this idea or the facility.
Great. I'll post this (with the fixups) for real tomorrow then, I guess.
A bit too late for me to do now.
> It does, however, remind me about about the classic problem of how bad
> we are at feature support detection because unrecognized attributes are
> ignored.
>
> I do really hope we can fully solve that problem some day.
Yes.
There may be two or more levels to this.
It wouldn't be hard to reject attributes that are higher than maxtype -
we already pass that to nla_parse() wherever we call it, but we'd have
to find a way to make it optional I guess, for compatibility reasons.
Perhaps with a warning, like attribute validation. For genetlink, a flag
in the family (something like "strict attribute validation") would be
easy, but for "netlink proper" we have a lot of nlmsg_parse() calls to
patch, and/or replace by nlmsg_parse_strict().
I guess we should
1) implement nlmsg_parse_strict() for those new things that want it
strictly - greenfield type stuff that doesn't need to work with
existing applications
2) add a warning to nlmsg_parse() when a too high attribute is
encountered
3) eventually replace nlmsg_parse() calls by nlmsg_parse_strict() and
see what breaks? :-) We won't be able to rely on that any time soon
though (unless userspace first checks with a guaranteed rejected
attribute, e.g. one that has NLA_REJECT, perhaps the u64 pad
attributes could be marked such since the kernel can't assume
alignment anyway)
Perhaps we also have too many calls to nlmsg_parse() without a policy,
but that's orthogonal to this check.
On a second level though, with complex things like nl80211 it's often
not clear at all which attributes are used with which commands. Some
attributes (like NL80211_ATTR_IFINDEX) are (almost) universal, but there
are others that aren't. Perhaps this isn't all that important, since if
you try to trigger scanning and at the same time tell the kernel about a
key index, that clearly makes no sense at all. OTOH, we have no good way
of discovering what attribute is used where - we (try to) document this
well in the nl80211.h kernel-doc, but that isn't always complete.
So more introspection (of sorts) could be useful.
While we're talking about wishlist, I'm also toying with the idea of
having some sort of generic mechanism to convert netlink attributes
to/from structs, for internal kernel representation; so far though I
haven't been able to come up with anything useful.
johannes
next prev parent reply other threads:[~2018-09-12 23:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-12 8:36 [RFC v2 1/2] netlink: add NLA_REJECT policy type Johannes Berg
2018-09-12 8:38 ` Johannes Berg
[not found] ` <20180912083610.20857-1-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2018-09-12 8:36 ` [RFC v2 2/2] netlink: add ethernet address policy types Johannes Berg
2018-09-12 8:49 ` Arend van Spriel
2018-09-12 8:50 ` Johannes Berg
2018-09-12 18:15 ` [RFC v2 1/2] netlink: add NLA_REJECT policy type David Miller
2018-09-12 18:34 ` Johannes Berg [this message]
[not found] ` <1536777285.3678.28.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2018-09-12 19:29 ` Michal Kubecek
2018-09-12 19:37 ` Johannes Berg
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=1536777285.3678.28.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=davem@davemloft.net \
--cc=linux-wireless@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).