netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] ixgbe: add NULL pointer check before calling xdp_rxq_info_reg
@ 2021-01-22 13:28 wangyunjian
  2021-01-22 17:54 ` [Intel-wired-lan] " Alexander Duyck
  0 siblings, 1 reply; 3+ messages in thread
From: wangyunjian @ 2021-01-22 13:28 UTC (permalink / raw)
  To: kuba, davem
  Cc: intel-wired-lan, netdev, jerry.lilijun, xudingke, Yunjian Wang

From: Yunjian Wang <wangyunjian@huawei.com>

The rx_ring->q_vector could be NULL, so it needs to be checked before
calling xdp_rxq_info_reg.

Fixes: b02e5a0ebb172 ("xsk: Propagate napi_id to XDP socket Rx path")
Addresses-Coverity: ("Dereference after null check")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
v2:
  * fix commit log
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 6cbbe09ce8a0..7b76b3f448f7 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -6586,8 +6586,9 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
 	rx_ring->next_to_use = 0;
 
 	/* XDP RX-queue info */
-	if (xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev,
-			     rx_ring->queue_index, rx_ring->q_vector->napi.napi_id) < 0)
+	if (rx_ring->q_vector && xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev,
+						  rx_ring->queue_index,
+						  rx_ring->q_vector->napi.napi_id) < 0)
 		goto err;
 
 	rx_ring->xdp_prog = adapter->xdp_prog;
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Intel-wired-lan] [PATCH net v2] ixgbe: add NULL pointer check before calling xdp_rxq_info_reg
  2021-01-22 13:28 [PATCH net v2] ixgbe: add NULL pointer check before calling xdp_rxq_info_reg wangyunjian
@ 2021-01-22 17:54 ` Alexander Duyck
  2021-01-23  0:13   ` Nguyen, Anthony L
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Duyck @ 2021-01-22 17:54 UTC (permalink / raw)
  To: wangyunjian
  Cc: Jakub Kicinski, David Miller, Netdev, intel-wired-lan,
	jerry.lilijun, xudingke

On Fri, Jan 22, 2021 at 5:29 AM wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> The rx_ring->q_vector could be NULL, so it needs to be checked before
> calling xdp_rxq_info_reg.
>
> Fixes: b02e5a0ebb172 ("xsk: Propagate napi_id to XDP socket Rx path")
> Addresses-Coverity: ("Dereference after null check")
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

This is kind of a big escape for the driver. From what I can tell it
looks like the "ethtool -t" test now causes a NULL pointer
dereference.

As far as the patch itself it looks good to me. This should probably
be pushed for any of the other Intel drivers that follow a similar
model as I suspect they were exhibit the same symptom with "ethtool
-t" triggering a NULL pointer dereference.

Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>

> ---
> v2:
>   * fix commit log
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index 6cbbe09ce8a0..7b76b3f448f7 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -6586,8 +6586,9 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
>         rx_ring->next_to_use = 0;
>
>         /* XDP RX-queue info */
> -       if (xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev,
> -                            rx_ring->queue_index, rx_ring->q_vector->napi.napi_id) < 0)
> +       if (rx_ring->q_vector && xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev,
> +                                                 rx_ring->queue_index,
> +                                                 rx_ring->q_vector->napi.napi_id) < 0)
>                 goto err;
>
>         rx_ring->xdp_prog = adapter->xdp_prog;
> --
> 2.23.0
>
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Intel-wired-lan] [PATCH net v2] ixgbe: add NULL pointer check before calling xdp_rxq_info_reg
  2021-01-22 17:54 ` [Intel-wired-lan] " Alexander Duyck
@ 2021-01-23  0:13   ` Nguyen, Anthony L
  0 siblings, 0 replies; 3+ messages in thread
From: Nguyen, Anthony L @ 2021-01-23  0:13 UTC (permalink / raw)
  To: wangyunjian, alexander.duyck
  Cc: netdev, jerry.lilijun, intel-wired-lan, kuba, xudingke, davem

On Fri, 2021-01-22 at 09:54 -0800, Alexander Duyck wrote:
> On Fri, Jan 22, 2021 at 5:29 AM wangyunjian <wangyunjian@huawei.com>
> wrote:
> > 
> > From: Yunjian Wang <wangyunjian@huawei.com>
> > 
> > The rx_ring->q_vector could be NULL, so it needs to be checked
> > before
> > calling xdp_rxq_info_reg.
> > 
> > Fixes: b02e5a0ebb172 ("xsk: Propagate napi_id to XDP socket Rx
> > path")
> > Addresses-Coverity: ("Dereference after null check")
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> 
> This is kind of a big escape for the driver. From what I can tell it
> looks like the "ethtool -t" test now causes a NULL pointer
> dereference.
> 
> As far as the patch itself it looks good to me. This should probably
> be pushed for any of the other Intel drivers that follow a similar
> model as I suspect they were exhibit the same symptom with "ethtool
> -t" triggering a NULL pointer dereference.

Thanks for the review Alex. We'll look into fixing the other Intel
drivers.

Thanks,
Tony

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-23  0:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 13:28 [PATCH net v2] ixgbe: add NULL pointer check before calling xdp_rxq_info_reg wangyunjian
2021-01-22 17:54 ` [Intel-wired-lan] " Alexander Duyck
2021-01-23  0:13   ` Nguyen, Anthony L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).