* [PATCH bpf] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link
@ 2023-11-27 13:43 Daniel Borkmann
2023-11-27 13:47 ` Nikolay Aleksandrov
2023-11-27 18:22 ` Jakub Kicinski
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Borkmann @ 2023-11-27 13:43 UTC (permalink / raw)
To: martin.lau; +Cc: razor, bpf, netdev, Daniel Borkmann
The IFLA_NETKIT_PEER_INFO attribute can only be used during device
creation, but not via changelink callback. Hence reject it there.
Fixes: 35dfaad7188c ("netkit, bpf: Add bpf programmable net device")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
drivers/net/netkit.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/netkit.c b/drivers/net/netkit.c
index 97bd6705c241..35553b16b8e2 100644
--- a/drivers/net/netkit.c
+++ b/drivers/net/netkit.c
@@ -851,6 +851,12 @@ static int netkit_change_link(struct net_device *dev, struct nlattr *tb[],
return -EACCES;
}
+ if (data[IFLA_NETKIT_PEER_INFO]) {
+ NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_INFO],
+ "netkit peer info cannot be changed after device creation");
+ return -EACCES;
+ }
+
if (data[IFLA_NETKIT_POLICY]) {
attr = data[IFLA_NETKIT_POLICY];
policy = nla_get_u32(attr);
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link
2023-11-27 13:43 [PATCH bpf] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link Daniel Borkmann
@ 2023-11-27 13:47 ` Nikolay Aleksandrov
2023-11-27 18:22 ` Jakub Kicinski
1 sibling, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2023-11-27 13:47 UTC (permalink / raw)
To: Daniel Borkmann, martin.lau; +Cc: bpf, netdev
On 11/27/23 15:43, Daniel Borkmann wrote:
> The IFLA_NETKIT_PEER_INFO attribute can only be used during device
> creation, but not via changelink callback. Hence reject it there.
>
> Fixes: 35dfaad7188c ("netkit, bpf: Add bpf programmable net device")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
> drivers/net/netkit.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/netkit.c b/drivers/net/netkit.c
> index 97bd6705c241..35553b16b8e2 100644
> --- a/drivers/net/netkit.c
> +++ b/drivers/net/netkit.c
> @@ -851,6 +851,12 @@ static int netkit_change_link(struct net_device *dev, struct nlattr *tb[],
> return -EACCES;
> }
>
> + if (data[IFLA_NETKIT_PEER_INFO]) {
> + NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_INFO],
> + "netkit peer info cannot be changed after device creation");
> + return -EACCES;
> + }
> +
> if (data[IFLA_NETKIT_POLICY]) {
> attr = data[IFLA_NETKIT_POLICY];
> policy = nla_get_u32(attr);
Good catch,
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link
2023-11-27 13:43 [PATCH bpf] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link Daniel Borkmann
2023-11-27 13:47 ` Nikolay Aleksandrov
@ 2023-11-27 18:22 ` Jakub Kicinski
2023-11-27 19:57 ` Daniel Borkmann
1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2023-11-27 18:22 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: martin.lau, razor, bpf, netdev
On Mon, 27 Nov 2023 14:43:11 +0100 Daniel Borkmann wrote:
> + if (data[IFLA_NETKIT_PEER_INFO]) {
> + NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_INFO],
> + "netkit peer info cannot be changed after device creation");
> + return -EACCES;
> + }
Why EACCES? It doesn't have much to do with permissions and all netlink
validation errors use EINVAL. IMO this is a basic case of "attribute
not defined in the policy", NLA_REJECT, so EINVAL..
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link
2023-11-27 18:22 ` Jakub Kicinski
@ 2023-11-27 19:57 ` Daniel Borkmann
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2023-11-27 19:57 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: martin.lau, razor, bpf, netdev
On 11/27/23 7:22 PM, Jakub Kicinski wrote:
> On Mon, 27 Nov 2023 14:43:11 +0100 Daniel Borkmann wrote:
>> + if (data[IFLA_NETKIT_PEER_INFO]) {
>> + NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_INFO],
>> + "netkit peer info cannot be changed after device creation");
>> + return -EACCES;
>> + }
>
> Why EACCES? It doesn't have much to do with permissions and all netlink
> validation errors use EINVAL. IMO this is a basic case of "attribute
> not defined in the policy", NLA_REJECT, so EINVAL..
Ok, sounds good, will use EINVAL instead in a v2.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-27 19:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-27 13:43 [PATCH bpf] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link Daniel Borkmann
2023-11-27 13:47 ` Nikolay Aleksandrov
2023-11-27 18:22 ` Jakub Kicinski
2023-11-27 19:57 ` Daniel Borkmann
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).