From: Stephen Hemminger <stephen@networkplumber.org>
To: David Ahern <dsa@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, jakub.kicinski@netronome.com
Subject: Re: [PATCH net-next iproute2 1/3] netlink: import netlink message parsing from kernel
Date: Tue, 2 May 2017 14:20:48 -0700 [thread overview]
Message-ID: <20170502142048.62670dc7@xeon-e3> (raw)
In-Reply-To: <91687d1a-0187-9e30-911b-f752af1c3be6@cumulusnetworks.com>
On Tue, 2 May 2017 14:39:40 -0600
David Ahern <dsa@cumulusnetworks.com> wrote:
> On 5/2/17 1:49 PM, Stephen Hemminger wrote:
> > I am not disagreeing that iproute2 should handle the extended
> > error format. Just want the solution to be as small as possible;
> > ie do no more than is absolutely necessary. And future proof
> > for the inevitable growth in new area.
>
> Understood. I was trying to not reinvent a wheel. nla_parse and
> nla_validate have not really been touched in 10 years, and both are well
> written with a good API to the rest of the code base.
>
> From there, I grabbed whole snippets as opposed to just taking what is
> needed for the ext-ack feature. I left the name as nlattr.c for easy
> diff if future code is wanted. The header file was renamed to nlattr.h
> to avoid confusion with other netlink.h files. Not adding it to
> libnetlink.h facilitates pulling more code via diff as needed.
>
> In short, I think it is good to re-use code from the kernel (lib and
> tools/lib) where possible and doing so in a way that makes updates as
> easy as header files.
The problem with copy and paste is that the code diverges and rots.
Also the security and error model in user space are different
> >
> >> +
> >> +static const __u8 nla_attr_minlen[NLA_TYPE_MAX+1] = {
> >> + [NLA_U8] = sizeof(__u8),
> >> + [NLA_U16] = sizeof(__u16),
> >> + [NLA_U32] = sizeof(__u32),
> >> + [NLA_U64] = sizeof(__u64),
> >> + [NLA_MSECS] = sizeof(__u64),
> >> + [NLA_NESTED] = NLA_HDRLEN,
> >> + [NLA_S8] = sizeof(__s8),
> >> + [NLA_S16] = sizeof(__s16),
> >> + [NLA_S32] = sizeof(__s32),
> >> + [NLA_S64] = sizeof(__s64),
> >> +};
> >> +
> >
> > This patch makes iproute2 now doing validation of netlink attributes
> > coming back from the kernel. What is the point, userspace should be
> > trusting the kernel.
>
> The kernel has bugs too; userspace should verify what it sends. In this
> case the policy validation is just data types -- a string was expected
> and a string was returned, or an attribute should be a u32 and it is.
> You can argue it is overkill for iproute2, but it is good coding practice.
>
> And for many netlink based features iproute2 tends to be the model that
> is copied into other code bases.
Then why only for new code.
I am not trying to be overly picky. Just that review is the time to play
devil's advocate and look for issues.
next prev parent reply other threads:[~2017-05-02 21:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-02 3:18 [PATCH net-next iproute2 0/3] ip: Initial support for extack errors David Ahern
2017-05-02 3:18 ` [PATCH net-next iproute2 1/3] netlink: import netlink message parsing from kernel David Ahern
2017-05-02 15:25 ` Stephen Hemminger
2017-05-02 16:51 ` David Ahern
2017-05-02 17:00 ` David Miller
2017-05-02 18:03 ` Stephen Hemminger
2017-05-02 18:39 ` David Ahern
2017-05-02 18:51 ` David Miller
2017-05-02 19:49 ` Stephen Hemminger
2017-05-02 20:39 ` David Ahern
2017-05-02 21:20 ` Stephen Hemminger [this message]
2017-05-02 3:18 ` [PATCH net-next iproute2 2/3] netlink: Add support for extended ack to rtnl_talk David Ahern
2017-05-02 3:18 ` [PATCH net-next iproute2 3/3] ip link: Add extack handling for setlink David Ahern
2017-05-02 3:34 ` [PATCH net-next iproute2 0/3] ip: Initial support for extack errors Jakub Kicinski
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=20170502142048.62670dc7@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=dsa@cumulusnetworks.com \
--cc=jakub.kicinski@netronome.com \
--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).