All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Kamal Heib <kheib@redhat.com>
Cc: netdev@vger.kernel.org, Veerasenareddy Burru <vburru@marvell.com>,
	Sathesh Edara <sedara@marvell.com>,
	Shinas Rasheed <srasheed@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net] net/octep_ep: Validate the VF ID
Date: Tue, 9 Sep 2025 09:19:23 +0200	[thread overview]
Message-ID: <aL/U+yTe08B4Qa2i@mev-dev.igk.intel.com> (raw)
In-Reply-To: <20250908231158.1333362-1-kheib@redhat.com>

On Mon, Sep 08, 2025 at 07:11:58PM -0400, Kamal Heib wrote:
> Make sure that the VF ID is valid before trying to access the VF.
> 
> Fixes: 8a241ef9b9b8 ("octeon_ep: add ndo ops for VFs in PF driver")
> Signed-off-by: Kamal Heib <kheib@redhat.com>
> ---
>  .../net/ethernet/marvell/octeon_ep/octep_main.c  | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> index 24499bb36c00..eaafbc0a55b1 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> @@ -1124,11 +1124,24 @@ static int octep_set_features(struct net_device *dev, netdev_features_t features
>  	return err;
>  }
>  
> +static bool octep_validate_vf(struct octep_device *oct, int vf)
nit, looks like octep_is_vf_valid() fits better here.

> +{
> +	if (vf >= CFG_GET_ACTIVE_VFS(oct->conf)) {
> +		dev_err(&oct->pdev->dev, "Invalid VF ID %d\n", vf);
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
>  static int octep_get_vf_config(struct net_device *dev, int vf,
>  			       struct ifla_vf_info *ivi)
>  {
>  	struct octep_device *oct = netdev_priv(dev);
>  
> +	if (!octep_validate_vf(oct, vf))
> +		return -EINVAL;
> +
>  	ivi->vf = vf;
>  	ether_addr_copy(ivi->mac, oct->vf_info[vf].mac_addr);
>  	ivi->spoofchk = true;
> @@ -1143,6 +1156,9 @@ static int octep_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
>  	struct octep_device *oct = netdev_priv(dev);
>  	int err;
>  
> +	if (!octep_validate_vf(oct, vf))
> +		return -EINVAL;
> +
>  	if (!is_valid_ether_addr(mac)) {
>  		dev_err(&oct->pdev->dev, "Invalid  MAC Address %pM\n", mac);
>  		return -EADDRNOTAVAIL;

Make sense, you can add reproduction steps and what happens when the ID
is incorrect, but it is up to you.

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

> -- 
> 2.51.0

      reply	other threads:[~2025-09-09  7:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08 23:11 [PATCH net] net/octep_ep: Validate the VF ID Kamal Heib
2025-09-09  7:19 ` Michal Swiatkowski [this message]

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=aL/U+yTe08B4Qa2i@mev-dev.igk.intel.com \
    --to=michal.swiatkowski@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=kheib@redhat.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sedara@marvell.com \
    --cc=srasheed@marvell.com \
    --cc=vburru@marvell.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.