Skip to contentSkip to conversation

net: mana: Fall back to standard MTU when PF reports adapter_mtu of 0

PATCH Applied Erni Sri Satya Vennela 4 participants 5 messages Jun 19 – Jun 25

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mana: Fall back to standard MTU when PF reports adapter_mtu of 0

Commit d7709812e13d ("net: mana: hardening: Validate adapter_mtu from MANA_QUERY_DEV_CONFIG") rejected any adapter_mtu value smaller than ETH_MIN_MTU + ETH_HLEN, including 0, returning -EPROTO and failing mana_probe().

Some older PF firmware versions still in the field report adapter_mtu as 0 in the MANA_QUERY_DEV_CONFIG response. With the hardening check in place, the MANA VF driver now fails to load on those hosts, breaking networking entirely for guests.

MANA hardware always supports the standard Ethernet MTU. Treat a reported adapter_mtu of 0 as "the PF did not advertise a value" and fall back to ETH_FRAME_LEN, the same value used for the pre-V2 message version path. Only jumbo frames remain unavailable until the PF reports a valid MTU.

Other small-but-nonzero bogus values are still rejected, preserving the original protection against the unsigned-subtraction wrap that would otherwise let ndev->max_mtu underflow to a huge value.

Fixes d7709812e13d ("net: mana: hardening: Validate adapter_mtu from MANA_QUERY_DEV_CONFIG")
---
 drivers/net/ethernet/microsoft/mana/mana_bpf.c |  3 ++-
 drivers/net/ethernet/microsoft/mana/mana_en.c  | 16 ++++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_bpf.c +2 -1
index b5e9bb184a1d..53308e139cbe 100644
@@ -237,7 +237,8 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
 		bpf_prog_put(old_prog);
 
 	if (prog)
-		ndev->max_mtu = MANA_XDP_MTU_MAX;
+		ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX,
+				      gc->adapter_mtu - ETH_HLEN);
 	else
 		ndev->max_mtu = gc->adapter_mtu - ETH_HLEN;
 
drivers/net/ethernet/microsoft/mana/mana_en.c +14 -2
index 87862b0434c7..7438ea6b3f26 100644
@@ -1233,12 +1233,24 @@ int mana_gd_query_device_cfg(struct gdma_context *gc, u32 proto_major_ver,
 	*max_num_vports = resp.max_num_vports;
 
 	if (resp.hdr.response.msg_version >= GDMA_MESSAGE_V2) {
-		if (resp.adapter_mtu < ETH_MIN_MTU + ETH_HLEN) {
+		if (resp.adapter_mtu == 0) {
+			/*
+			 * Some older PF firmware versions report an
+			 * adapter_mtu of 0. MANA hardware always supports the
+			 * standard Ethernet MTU, so fall back to ETH_FRAME_LEN.
+			 * Jumbo frames will not be available in this case.
+			 */
+			dev_info(dev,
+				 "PF reported adapter_mtu of 0, falling back to %u (jumbo frames disabled)\n",
+				 ETH_FRAME_LEN);
+			gc->adapter_mtu = ETH_FRAME_LEN;
+		} else if (resp.adapter_mtu < ETH_MIN_MTU + ETH_HLEN) {
 			dev_err(dev, "Adapter MTU too small: %u\n",
 				resp.adapter_mtu);
 			return -EPROTO;
+		} else {
+			gc->adapter_mtu = resp.adapter_mtu;
 		}
-		gc->adapter_mtu = resp.adapter_mtu;
 	} else {
 		gc->adapter_mtu = ETH_FRAME_LEN;
 	}
Signature · 1 line
2.34.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Preexisting error handling bug in XDP set path leaves apc->bpf_prog pointing to a freed BPF program, leading to a Use-After-Free/Double Free. --

commit 425f6bf5274f2172e13cdc649ea2288d8dc1ad72
Author: Erni Sri Satya Vennela <[email protected]>

net: mana: Fall back to standard MTU when PF reports adapter_mtu of 0

This commit fixes a regression for older PF firmware versions by allowing an adapter_mtu of 0 to fall back to the standard ETH_FRAME_LEN. It also updates MTU bounds checks for XDP limits.

drivers/net/ethernet/microsoft/mana/mana_bpf.c static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, · line 241

Quoted 11 lines
drivers/net/ethernet/microsoft/mana/mana_bpf.c +2 -1
index b5e9bb184a1dd..53308e139cbe9 100644
@@ -237,7 +237,8 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
 		bpf_prog_put(old_prog);
 
 	if (prog)
-		ndev->max_mtu = MANA_XDP_MTU_MAX;
+		ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX,
+				      gc->adapter_mtu - ETH_HLEN);

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the changes to mana_xdp_set(), I noticed a pre-existing issue on an error path earlier in this function.

Earlier in mana_xdp_set(), the program is assigned:

    apc->bpf_prog = prog;

If the port is up, it then allocates rx buffers:

    err = mana_pre_alloc_rxbufs(apc, ndev->mtu, apc->num_queues);
    if (err) {
        ...
        return err;
    }

If mana_pre_alloc_rxbufs() fails, it returns directly rather than jumping to the err_dealloc_rxbuffs label. This bypasses the cleanup step that restores apc->bpf_prog = old_prog.

Since the networking core frees the bpf program on error, does this leave apc->bpf_prog pointing to a freed program?

If mana_xdp_set() is called again later, could fetching old_prog lead to a use-after-free or double-free when calling bpf_prog_put(old_prog)?

Quoted 3 lines
drivers/net/ethernet/microsoft/mana/mana_bpf.c +0 -0
 	else
 		ndev->max_mtu = gc->adapter_mtu - ETH_HLEN;
 
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
Quoted 51 lines · On Sat, Jun 20, 2026 at 05:54:06AM +0000, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Preexisting error handling bug in XDP set path leaves apc->bpf_prog pointing to a freed BPF program, leading to a Use-After-Free/Double Free. --

commit 425f6bf5274f2172e13cdc649ea2288d8dc1ad72
Author: Erni Sri Satya Vennela <[email protected]>

net: mana: Fall back to standard MTU when PF reports adapter_mtu of 0

This commit fixes a regression for older PF firmware versions by allowing an adapter_mtu of 0 to fall back to the standard ETH_FRAME_LEN. It also updates MTU bounds checks for XDP limits.

drivers/net/ethernet/microsoft/mana/mana_bpf.c static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, · line 241

Quoted 11 lines
drivers/net/ethernet/microsoft/mana/mana_bpf.c +2 -1
index b5e9bb184a1dd..53308e139cbe9 100644
@@ -237,7 +237,8 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
 		bpf_prog_put(old_prog);
 
 	if (prog)
-		ndev->max_mtu = MANA_XDP_MTU_MAX;
+		ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX,
+				      gc->adapter_mtu - ETH_HLEN);

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the changes to mana_xdp_set(), I noticed a pre-existing issue on an error path earlier in this function.

Earlier in mana_xdp_set(), the program is assigned:

    apc->bpf_prog = prog;

If the port is up, it then allocates rx buffers:

    err = mana_pre_alloc_rxbufs(apc, ndev->mtu, apc->num_queues);
    if (err) {
        ...
        return err;
    }

If mana_pre_alloc_rxbufs() fails, it returns directly rather than jumping to the err_dealloc_rxbuffs label. This bypasses the cleanup step that restores apc->bpf_prog = old_prog.

Since the networking core frees the bpf program on error, does this leave apc->bpf_prog pointing to a freed program?

Quoted 9 lines

If mana_xdp_set() is called again later, could fetching old_prog lead to a use-after-free or double-free when calling bpf_prog_put(old_prog)?

Quoted 3 lines
drivers/net/ethernet/microsoft/mana/mana_bpf.c +0 -0
 	else
 		ndev->max_mtu = gc->adapter_mtu - ETH_HLEN;
 
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

I'll take this up in a different patch.

Thankyou,
Vennela

reviewer Reviewed-by on v1 1/1
#3 lore raw
In reply to Erni Sri Satya Vennela
Quoted 16 lines · Erni Sri Satya Vennela

Commit d7709812e13d ("net: mana: hardening: Validate adapter_mtu from MANA_QUERY_DEV_CONFIG") rejected any adapter_mtu value smaller than ETH_MIN_MTU + ETH_HLEN, including 0, returning -EPROTO and failing mana_probe().

Some older PF firmware versions still in the field report adapter_mtu as 0 in the MANA_QUERY_DEV_CONFIG response. With the hardening check in place, the MANA VF driver now fails to load on those hosts, breaking networking entirely for guests.

MANA hardware always supports the standard Ethernet MTU. Treat a reported adapter_mtu of 0 as "the PF did not advertise a value" and fall back to ETH_FRAME_LEN, the same value used for the pre-V2 message version path. Only jumbo frames remain unavailable until the PF reports a valid MTU.

Quoted 6 lines

Other small-but-nonzero bogus values are still rejected, preserving the original protection against the unsigned-subtraction wrap that would otherwise let ndev->max_mtu underflow to a huge value.

Fixes d7709812e13d ("net: mana: hardening: Validate adapter_mtu from MANA_QUERY_DEV_CONFIG")

FTR, I agree with your assessment that the issue flagged in the AI-generated review of this patch on sashiko.dev can be treated as a follow-up [1].

And I don't think the low priority issue flagged in the AI-generated review on https://netdev-ai.bots.linux.dev/sashiko/ should impede progress of this patch.

[1] https://lore.kernel.org/bpf/ajj+5mhswcqhI2z7@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net/

#4 lore raw
In reply to Erni Sri Satya Vennela
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Thu, 18 Jun 2026 22:53:38 -0700 you wrote:

Commit d7709812e13d ("net: mana: hardening: Validate adapter_mtu from MANA_QUERY_DEV_CONFIG") rejected any adapter_mtu value smaller than ETH_MIN_MTU + ETH_HLEN, including 0, returning -EPROTO and failing mana_probe().

Some older PF firmware versions still in the field report adapter_mtu as 0 in the MANA_QUERY_DEV_CONFIG response. With the hardening check in place, the MANA VF driver now fails to load on those hosts, breaking networking entirely for guests.

[...]

Here is the summary with links:
- [net] net: mana: Fall back to standard MTU when PF reports adapter_mtu of 0

    https://git.kernel.org/netdev/net/c/6bd81a5b4e0d

You are awesome, thank you!

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