From: Michal Kubecek <mkubecek@suse.cz>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: David Miller <davem@davemloft.net>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [RFC v2 1/2] netlink: add NLA_REJECT policy type
Date: Wed, 12 Sep 2018 21:29:26 +0200 [thread overview]
Message-ID: <20180912192925.GD29691@unicorn.suse.cz> (raw)
In-Reply-To: <1536777285.3678.28.camel@sipsolutions.net>
On Wed, Sep 12, 2018 at 08:34:45PM +0200, Johannes Berg wrote:
> 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)
I'm not so sure we (eventually) want to reject unknown attributes
everywhere. I don't have any concrete example in mind but I think there
will be use cases where we want to ignore unrecognized attributes
(probably per parse call). But it makes sense to require caller to
explicitely declare this is the case.
> 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.
I was also thinking about something like this. One motivation was to
design extensible version of ethtool_ops, the other was allowing complex
data types (structures, arrays) for ethtool tunables. But I have nothing
more than a vague idea so far.
Michal Kubecek
WARNING: multiple messages have this Message-ID (diff)
From: Michal Kubecek <mkubecek-AlSwsSmVLrQ@public.gmane.org>
To: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
Cc: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC v2 1/2] netlink: add NLA_REJECT policy type
Date: Wed, 12 Sep 2018 21:29:26 +0200 [thread overview]
Message-ID: <20180912192925.GD29691@unicorn.suse.cz> (raw)
In-Reply-To: <1536777285.3678.28.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
On Wed, Sep 12, 2018 at 08:34:45PM +0200, Johannes Berg wrote:
> 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)
I'm not so sure we (eventually) want to reject unknown attributes
everywhere. I don't have any concrete example in mind but I think there
will be use cases where we want to ignore unrecognized attributes
(probably per parse call). But it makes sense to require caller to
explicitely declare this is the case.
> 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.
I was also thinking about something like this. One motivation was to
design extensible version of ethtool_ops, the other was allowing complex
data types (structures, arrays) for ethtool tunables. But I have nothing
more than a vague idea so far.
Michal Kubecek
next prev parent reply other threads:[~2018-09-13 0:35 UTC|newest]
Thread overview: 13+ 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:36 ` Johannes Berg
2018-09-12 8:36 ` [RFC v2 2/2] netlink: add ethernet address policy types Johannes Berg
2018-09-12 8:36 ` Johannes Berg
2018-09-12 8:49 ` Arend van Spriel
2018-09-12 8:50 ` Johannes Berg
2018-09-12 8:38 ` [RFC v2 1/2] netlink: add NLA_REJECT policy type Johannes Berg
2018-09-12 18:15 ` David Miller
2018-09-12 18:15 ` David Miller
2018-09-12 18:34 ` Johannes Berg
2018-09-12 19:29 ` Michal Kubecek [this message]
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=20180912192925.GD29691@unicorn.suse.cz \
--to=mkubecek@suse.cz \
--cc=davem@davemloft.net \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--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 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.