Skip to contentSkip to conversation

netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link

PATCH Applied Daniel Borkmann 3 participants 3 messages Nov 27, 2023 – Nov 28, 2023

Subsystems (4)
lore
Share & tools
lore

Daniel Borkmann

author maintainer
#0 lore raw

PATCH v2 1/1 netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link

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")
Cc Jakub Kicinski <[email protected]>

---
v1 -> v2:
- Switch error code from EACCES to EINVAL (Jakub)

 drivers/net/netkit.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/netkit.c +6 -0
index 97bd6705c241..39171380ccf2 100644
@@ -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 -EINVAL;
+	}
+
 	if (data[IFLA_NETKIT_POLICY]) {
 		attr = data[IFLA_NETKIT_POLICY];
 		policy = nla_get_u32(attr);
Signature · 1 line
2.21.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · On Mon, 27 Nov 2023 21:05:33 +0100 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")
Cc Jakub Kicinski <[email protected]>
#2 lore raw
In reply to Daniel Borkmann
This patch was applied to bpf/bpf.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf.git (master)
by Martin KaFai Lau <[email protected]>:

Quoted 9 lines · On Mon, 27 Nov 2023 21:05:33 +0100 you 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")
Cc Jakub Kicinski <[email protected]>

[...]

Here is the summary with links:
- [bpf,v2] netkit: Reject IFLA_NETKIT_PEER_INFO in netkit_change_link

    https://git.kernel.org/bpf/bpf/c/0bad281d0ecd

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html