From: Jakub Kicinski <kuba@kernel.org>
To: anthony.l.nguyen@intel.com
Cc: Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, pabeni@redhat.com, edumazet@google.com,
andrew+netdev@lunn.ch, netdev@vger.kernel.org,
moonafterrain@outlook.com, przemyslaw.kitszel@intel.com,
danisjiang@gmail.com, stable@vger.kernel.org,
aleksandr.loktionov@intel.com, horms@kernel.org,
rafal.romanowski@intel.com
Subject: Re: [PATCH net 13/13] iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response
Date: Thu, 23 Jul 2026 08:57:55 -0700 [thread overview]
Message-ID: <20260723155755.717968-1-kuba@kernel.org> (raw)
In-Reply-To: <20260717185340.3595286-14-anthony.l.nguyen@intel.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response
This patch clamps the num_vsis field from the PF's
VIRTCHNL_OP_GET_VF_RESOURCES response so that the loop bound used when
iterating over the fixed-size vsi_res[] buffer cannot exceed what the
received message length can cover.
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> index ec234cc8bd9d..c4039d2b24a4 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
[ ... ]
> @@ -300,7 +316,7 @@ int iavf_get_vf_config(struct iavf_adapter *adapter)
> * we aren't getting too many queues
> */
> if (!err)
> - iavf_validate_num_queues(adapter);
> + iavf_validate_num_queues(adapter, min(event.msg_len, len));
> iavf_vf_parse_hw_config(hw, adapter->vf_res);
>
> kfree(event.msg_buf);
[High]
Does the error path in iavf_get_vf_config() still allow the
out-of-bounds access on vsi_res[] that the commit message describes?
Looking at the surrounding code:
err = iavf_poll_virtchnl_msg(hw, &event, VIRTCHNL_OP_GET_VF_RESOURCES);
memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
/* some PFs send more queues than we should have so validate that
* we aren't getting too many queues
*/
if (!err)
iavf_validate_num_queues(adapter, min(event.msg_len, len));
iavf_vf_parse_hw_config(hw, adapter->vf_res);
The memcpy of the PF-supplied payload into adapter->vf_res runs
unconditionally, but the new num_vsis clamp is only invoked when err is
zero.
iavf_poll_virtchnl_msg() returns virtchnl_status_to_errno(v_retval), so a
PF response carrying a non-success v_retval together with an
attacker-controlled msg_buf would still populate adapter->vf_res with the
raw num_vsis value and then skip the clamp.
iavf_vf_parse_hw_config() runs unconditionally after that and iterates
based on the unclamped u16 num_vsis:
for (i = 0; i < msg->num_vsis; i++) {
if (vsi_res->vsi_type == VIRTCHNL_VSI_SRIOV) {
ether_addr_copy(hw->mac.perm_addr,
vsi_res->default_mac_addr);
ether_addr_copy(hw->mac.addr,
vsi_res->default_mac_addr);
}
vsi_res++;
}
vsi_res[] is a fixed-size array of IAVF_MAX_VF_VSI (3) entries in the
adapter->vf_res allocation, so num_vsis up to 65535 would walk far past
that buffer, and any OOB slot whose vsi_type happens to equal
VIRTCHNL_VSI_SRIOV would additionally copy six bytes of adjacent heap
memory into hw->mac.perm_addr and hw->mac.addr.
Would it make sense to either apply the num_vsis clamp unconditionally,
or gate the memcpy and iavf_vf_parse_hw_config() behind the same
if (!err) as the validation, so that the error path cannot reintroduce
the out-of-bounds access this patch is meant to close?
next prev parent reply other threads:[~2026-07-23 15:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 18:53 [PATCH net 00/13][pull request] Intel Wired LAN Driver Updates 2026-07-17 (ice, idpf, iavf) Tony Nguyen
2026-07-17 18:53 ` [PATCH net 01/13] ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV Tony Nguyen
2026-07-17 18:53 ` [PATCH net 02/13] ice: remove redundant switchdev check in ice_eswitch_attach_vf() Tony Nguyen
2026-07-17 18:53 ` [PATCH net 03/13] ice: pass the return value of skb_checksum_help() Tony Nguyen
2026-07-17 18:53 ` [PATCH net 04/13] ice: always do GCS if hardware supports it Tony Nguyen
2026-07-17 18:53 ` [PATCH net 05/13] ice: use NETIF_F_HW_CSUM instead of IP/IPV6 Tony Nguyen
2026-07-23 15:55 ` Jakub Kicinski
2026-07-17 18:53 ` [PATCH net 06/13] ice: fix LAG recipe to profile association Tony Nguyen
2026-07-17 18:53 ` [PATCH net 07/13] ice: support SBQ posted writes with non-posted support for CGU Tony Nguyen
2026-07-23 15:57 ` Jakub Kicinski
2026-07-17 18:53 ` [PATCH net 08/13] ice: use READ_ONCE() to access cached PHC time Tony Nguyen
2026-07-17 18:53 ` [PATCH net 09/13] ice: fix PTP Call Trace during PTP release Tony Nguyen
2026-07-17 18:53 ` [PATCH net 10/13] ice: prevent tstamp ring allocation for non-PF VSI types Tony Nguyen
2026-07-17 18:53 ` [PATCH net 11/13] ice: reject out-of-range ptype in ice_parser_profile_init Tony Nguyen
2026-07-17 18:53 ` [PATCH net 12/13] idpf: fix max_vport related crash on allocation error during init Tony Nguyen
2026-07-17 18:53 ` [PATCH net 13/13] iavf: validate num_vsis in VIRTCHNL_OP_GET_VF_RESOURCES response Tony Nguyen
2026-07-23 15:57 ` Jakub Kicinski [this message]
2026-07-23 16:10 ` [PATCH net 00/13][pull request] Intel Wired LAN Driver Updates 2026-07-17 (ice, idpf, iavf) 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=20260723155755.717968-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=danisjiang@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=moonafterrain@outlook.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=rafal.romanowski@intel.com \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox