mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-11-10 20:48:12 +00:00
net: enetc: add trusted VF support
Some mailbox messages require a higher privilege level to be executed on behalf of the requesting VF. Introduce a trusted VF flag (ENETC_VF_FLAG_TRUSTED) and wire up the ndo_set_vf_trust callback via enetc_pf_set_vf_trust(), which is shared between the enetc and enetc4 PF drivers. Trust is a PF/host-side policy bound to the VF index, decoupled from whether SR-IOV is enabled. It may be set on a slot before SR-IOV is enabled so a trusted VF can apply configuration right at init time, and it is intentionally preserved across an SR-IOV disable/enable cycle. The bounds check uses pf->total_vfs, the hardware maximum and the size of pf->vf_state[], so pre-configuring an uninstantiated slot is in-bounds. If a slot may be reassigned to another guest, the admin clears trust with "ip link set <dev> vf <N> trust off". The first message gated on trust is the VF primary MAC address change. An untrusted VF that attempts to set its own MAC address will receive a ENETC_MSG_CLASS_ID_PERMISSION_DENY response and the hardware will not be programmed. This prevents a malicious VM from setting the VF address to the MAC address of other VFs or the PF and eavesdropping on the traffic of other SIs, and it stops a malicious VM from arbitrarily changing the VF MAC address to achieve MAC address spoofing and bypass security policies. This does not regress VF bring-up. The PF programs a valid primary MAC into every VF slot at probe, and the VF loads it from its own SIPMAR0/1 registers. Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-2-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
20d1b74a32
commit
aeb505f83f
6 changed files with 61 additions and 10 deletions
Loading…
Add table
Add a link
Reference in a new issue