From: Nikolay Aleksandrov <razor@blackwall.org>
To: Ido Schimmel <idosch@idosch.org>
Cc: bpf@vger.kernel.org, jiri@resnulli.us, netdev@vger.kernel.org,
martin.lau@linux.dev, ast@kernel.org, andrii@kernel.org,
john.fastabend@gmail.com, kuba@kernel.org, andrew@lunn.ch,
toke@kernel.org, toke@redhat.com, sdf@google.com,
daniel@iogearbox.net
Subject: Re: [PATCH bpf-next 2/2] netkit: use netlink policy for mode and policy attributes validation
Date: Thu, 26 Oct 2023 17:34:05 +0300 [thread overview]
Message-ID: <5f2655c0-8e66-4aa4-a94a-e6a45be44105@blackwall.org> (raw)
In-Reply-To: <36072f45-0d42-7284-d0dc-295f543fe40f@blackwall.org>
On 10/26/23 17:23, Nikolay Aleksandrov wrote:
> On 10/26/23 17:11, Ido Schimmel wrote:
>> On Thu, Oct 26, 2023 at 12:41:06PM +0300, Nikolay Aleksandrov wrote:
>>> static const struct nla_policy netkit_policy[IFLA_NETKIT_MAX + 1] = {
>>> [IFLA_NETKIT_PEER_INFO] = { .len = sizeof(struct
>>> ifinfomsg) },
>>> - [IFLA_NETKIT_POLICY] = { .type = NLA_U32 },
>>> - [IFLA_NETKIT_MODE] = { .type = NLA_U32 },
>>> - [IFLA_NETKIT_PEER_POLICY] = { .type = NLA_U32 },
>>> + [IFLA_NETKIT_POLICY] = NLA_POLICY_VALIDATE_FN(NLA_U32,
>>> + netkit_check_policy),
>>
>> Nik, it's problematic to use NLA_POLICY_VALIDATE_FN() with anything
>> other than NLA_BINARY. See commit 9e17f99220d1 ("net/sched: act_mpls:
>> Fix warning during failed attribute validation").
>>
>
> But how is that code called at all? The validation type is
> NLA_VALIDATE_FUNCTION(), not NLA_VALIDATE_MIN/MAX/RANGE/RANGE_WARN...
> nla_validate_int_range() is called only on:
> case NLA_VALIDATE_RANGE_PTR:
> case NLA_VALIDATE_RANGE:
> case NLA_VALIDATE_RANGE_WARN_TOO_LONG:
> case NLA_VALIDATE_MIN:
> case NLA_VALIDATE_MAX:
>
Ah, I'm looking at the wrong thing.. I saw the problem. :)
> Anyway, I'll switch to NLA_BINARY in a bit to make sure it's ok. Thanks
> for the pointer.
>
>>> + [IFLA_NETKIT_MODE] = NLA_POLICY_VALIDATE_FN(NLA_U32,
>>> + netkit_check_mode),
>>> + [IFLA_NETKIT_PEER_POLICY] = NLA_POLICY_VALIDATE_FN(NLA_U32,
>>> + netkit_check_policy),
>>> [IFLA_NETKIT_PRIMARY] = { .type = NLA_REJECT,
>>> .reject_message = "Primary attribute is
>>> read-only" },
>>> };
>>> --
>>> 2.38.1
>>>
>>>
>
next prev parent reply other threads:[~2023-10-26 14:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 9:41 [PATCH bpf-next 0/2] netkit: two minor cleanups Nikolay Aleksandrov
2023-10-26 9:41 ` [PATCH bpf-next 1/2] netkit: remove explicit active/peer ptr initialization Nikolay Aleksandrov
2023-10-26 12:12 ` Daniel Borkmann
2023-10-26 13:21 ` Jiri Pirko
2023-10-26 9:41 ` [PATCH bpf-next 2/2] netkit: use netlink policy for mode and policy attributes validation Nikolay Aleksandrov
2023-10-26 12:13 ` Daniel Borkmann
2023-10-26 13:23 ` Jiri Pirko
2023-10-26 14:11 ` Ido Schimmel
2023-10-26 14:23 ` Nikolay Aleksandrov
2023-10-26 14:25 ` Daniel Borkmann
2023-10-26 14:34 ` Nikolay Aleksandrov [this message]
2023-10-26 14:10 ` [PATCH bpf-next 0/2] netkit: two minor cleanups patchwork-bot+netdevbpf
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=5f2655c0-8e66-4aa4-a94a-e6a45be44105@blackwall.org \
--to=razor@blackwall.org \
--cc=andrew@lunn.ch \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=idosch@idosch.org \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=toke@kernel.org \
--cc=toke@redhat.com \
/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.