[dpdk-dev,v3,1/4] net/virtio: fix add pointer checking
Checks
Commit Message
It is necessary to add pointer checking because in some case the
code will cause crash. For example, the code goes here before
memory allocation of rxvq is finished.
Fixes: 7365504f77e3("net/virtio: support guest announce")
Cc: stable@dpdk.org
Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
On 3/21/2018 11:03 AM, zhiyong.yang@intel.com wrote:
> It is necessary to add pointer checking because in some case the
> code will cause crash. For example, the code goes here before
> memory allocation of rxvq is finished.
>
> Fixes: 7365504f77e3("net/virtio: support guest announce")
> Cc: stable@dpdk.org
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
This fix is not related to the topic of this patch series, correct?
Maybe next time, we can put it out of the patch series.
Reviewed-by: Jianfeng Tan <jianfeng.tan@intel.com>
Thanks,
Jianfeng
> ---
> drivers/net/virtio/virtio_ethdev.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 884f74ad0..f377d8aa3 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1273,9 +1273,13 @@ static void
> virtio_notify_peers(struct rte_eth_dev *dev)
> {
> struct virtio_hw *hw = dev->data->dev_private;
> - struct virtnet_rx *rxvq = dev->data->rx_queues[0];
> + struct virtnet_rx *rxvq;
> struct rte_mbuf *rarp_mbuf;
>
> + if (!dev->data->rx_queues)
> + return;
> +
> + rxvq = dev->data->rx_queues[0];
> rarp_mbuf = rte_net_make_rarp_packet(rxvq->mpool,
> (struct ether_addr *)hw->mac_addr);
> if (rarp_mbuf == NULL) {
> -----Original Message-----
> From: Tan, Jianfeng
> Sent: Wednesday, March 28, 2018 3:26 PM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>; dev@dpdk.org
> Cc: Wang, Zhihong <zhihong.wang@intel.com>;
> maxime.coquelin@redhat.com; thomas@monjalon.net; Wang, Dong1
> <dong1.wang@intel.com>; Bie, Tiwei <tiwei.bie@intel.com>;
> stable@dpdk.org
> Subject: Re: [PATCH v3 1/4] net/virtio: fix add pointer checking
>
>
>
> On 3/21/2018 11:03 AM, zhiyong.yang@intel.com wrote:
> > It is necessary to add pointer checking because in some case the code
> > will cause crash. For example, the code goes here before memory
> > allocation of rxvq is finished.
> >
> > Fixes: 7365504f77e3("net/virtio: support guest announce")
> > Cc: stable@dpdk.org
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
>
> This fix is not related to the topic of this patch series, correct?
> Maybe next time, we can put it out of the patch series.
>
> Reviewed-by: Jianfeng Tan <jianfeng.tan@intel.com>
>
> Thanks,
> Jianfeng
>
Thanks for Jianfeng's review. The bug must be fixed firstly in order
that code can go in the right way for virito-user server mode patch. :)
Thanks
Zhiyong
On 03/21/2018 04:03 AM, zhiyong.yang@intel.com wrote:
> It is necessary to add pointer checking because in some case the
> code will cause crash. For example, the code goes here before
> memory allocation of rxvq is finished.
>
> Fixes: 7365504f77e3("net/virtio: support guest announce")
> Cc: stable@dpdk.org
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> ---
> drivers/net/virtio/virtio_ethdev.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 884f74ad0..f377d8aa3 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1273,9 +1273,13 @@ static void
> virtio_notify_peers(struct rte_eth_dev *dev)
> {
> struct virtio_hw *hw = dev->data->dev_private;
> - struct virtnet_rx *rxvq = dev->data->rx_queues[0];
> + struct virtnet_rx *rxvq;
> struct rte_mbuf *rarp_mbuf;
>
> + if (!dev->data->rx_queues)
> + return;
> +
> + rxvq = dev->data->rx_queues[0];
> rarp_mbuf = rte_net_make_rarp_packet(rxvq->mpool,
> (struct ether_addr *)hw->mac_addr);
> if (rarp_mbuf == NULL) {
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
On 03/21/2018 04:03 AM, zhiyong.yang@intel.com wrote:
> It is necessary to add pointer checking because in some case the
> code will cause crash. For example, the code goes here before
> memory allocation of rxvq is finished.
>
> Fixes: 7365504f77e3("net/virtio: support guest announce")
> Cc: stable@dpdk.org
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> ---
> drivers/net/virtio/virtio_ethdev.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 884f74ad0..f377d8aa3 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1273,9 +1273,13 @@ static void
> virtio_notify_peers(struct rte_eth_dev *dev)
> {
> struct virtio_hw *hw = dev->data->dev_private;
> - struct virtnet_rx *rxvq = dev->data->rx_queues[0];
> + struct virtnet_rx *rxvq;
> struct rte_mbuf *rarp_mbuf;
>
> + if (!dev->data->rx_queues)
> + return;
> +
> + rxvq = dev->data->rx_queues[0];
> rarp_mbuf = rte_net_make_rarp_packet(rxvq->mpool,
> (struct ether_addr *)hw->mac_addr);
> if (rarp_mbuf == NULL) {
>
Applied to dpdk-next-virtio/master.
Thanks,
Maxime
@@ -1273,9 +1273,13 @@ static void
virtio_notify_peers(struct rte_eth_dev *dev)
{
struct virtio_hw *hw = dev->data->dev_private;
- struct virtnet_rx *rxvq = dev->data->rx_queues[0];
+ struct virtnet_rx *rxvq;
struct rte_mbuf *rarp_mbuf;
+ if (!dev->data->rx_queues)
+ return;
+
+ rxvq = dev->data->rx_queues[0];
rarp_mbuf = rte_net_make_rarp_packet(rxvq->mpool,
(struct ether_addr *)hw->mac_addr);
if (rarp_mbuf == NULL) {