public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Daniil Tatianin <d-tatianin@yandex-team.ru>
Cc: Ariel Elior <aelior@marvell.com>,
	Manish Chopra <manishc@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Yuval Mintz <Yuval.Mintz@qlogic.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] qed/qed_sriov: guard against NULL derefs from qed_iov_get_vf_info
Date: Thu, 16 Mar 2023 11:47:19 +0100	[thread overview]
Message-ID: <ZBLzt+tS/SKO9IGC@localhost.localdomain> (raw)
In-Reply-To: <20230316102921.609266-1-d-tatianin@yandex-team.ru>

On Thu, Mar 16, 2023 at 01:29:21PM +0300, Daniil Tatianin wrote:
> We have to make sure that the info returned by the helper is valid
> before using it.
> 
> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> static analysis tool.
> 
> Fixes: f990c82c385b ("qed*: Add support for ndo_set_vf_trust")
> Fixes: 733def6a04bf ("qed*: IOV link control")
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> ---
> Changes since v1:
> - Add a vf check to qed_iov_handle_trust_change as well
> ---
>  drivers/net/ethernet/qlogic/qed/qed_sriov.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
> index 2bf18748581d..fa167b1aa019 100644
> --- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
> +++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
> @@ -4404,6 +4404,9 @@ qed_iov_configure_min_tx_rate(struct qed_dev *cdev, int vfid, u32 rate)
>  	}
>  
>  	vf = qed_iov_get_vf_info(QED_LEADING_HWFN(cdev), (u16)vfid, true);
> +	if (!vf)
> +		return -EINVAL;
> +
>  	vport_id = vf->vport_id;
>  
>  	return qed_configure_vport_wfq(cdev, vport_id, rate);
> @@ -5152,7 +5155,7 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn)
>  
>  		/* Validate that the VF has a configured vport */
>  		vf = qed_iov_get_vf_info(hwfn, i, true);
> -		if (!vf->vport_instance)
> +		if (!vf || !vf->vport_instance)
>  			continue;
>  
>  		memset(&params, 0, sizeof(params));
> -- 
> 2.25.1
> 

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


  reply	other threads:[~2023-03-16 10:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 10:29 [PATCH v2] qed/qed_sriov: guard against NULL derefs from qed_iov_get_vf_info Daniil Tatianin
2023-03-16 10:47 ` Michal Swiatkowski [this message]
2023-03-19  8:50 ` 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=ZBLzt+tS/SKO9IGC@localhost.localdomain \
    --to=michal.swiatkowski@linux.intel.com \
    --cc=Yuval.Mintz@qlogic.com \
    --cc=aelior@marvell.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishc@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox