From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"Wang, YuanX" <yuanx.wang@intel.com>,
"david.marchand@redhat.com" <david.marchand@redhat.com>
Cc: "stable@dpdk.org" <stable@dpdk.org>
Subject: RE: [PATCH] vhost: fix unsafe vrings addresses modifications
Date: Thu, 17 Feb 2022 07:32:29 +0000 [thread overview]
Message-ID: <SN6PR11MB350427A4DDE8AEC713AD71E99C369@SN6PR11MB3504.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220127110953.499464-1-maxime.coquelin@redhat.com>
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Thursday, January 27, 2022 7:10 PM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Wang, YuanX
> <yuanx.wang@intel.com>; david.marchand@redhat.com
> Cc: stable@dpdk.org; Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH] vhost: fix unsafe vrings addresses modifications
>
> This patch adds missing protection around vring_invalidate
> and translate_ring_addresses calls in vhost_user_iotlb_msg.
>
> Fixes: eefac9536a90 ("vhost: postpone device creation until rings are mapped")
> Cc: stable@dpdk.org
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> lib/vhost/vhost_user.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 5eb1dd6812..ae8513c465 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -2566,8 +2566,11 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct
> VhostUserMsg *msg,
> vhost_user_iotlb_cache_insert(vq, imsg->iova, vva,
> len, imsg->perm);
>
> - if (is_vring_iotlb(dev, vq, imsg))
> + if (is_vring_iotlb(dev, vq, imsg)) {
> + rte_spinlock_lock(&vq->access_lock);
> *pdev = dev = translate_ring_addresses(dev, i);
> + rte_spinlock_unlock(&vq->access_lock);
> + }
> }
> break;
> case VHOST_IOTLB_INVALIDATE:
> @@ -2580,8 +2583,11 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct
> VhostUserMsg *msg,
> vhost_user_iotlb_cache_remove(vq, imsg->iova,
> imsg->size);
>
> - if (is_vring_iotlb(dev, vq, imsg))
> + if (is_vring_iotlb(dev, vq, imsg)) {
> + rte_spinlock_lock(&vq->access_lock);
> vring_invalidate(dev, vq);
> + rte_spinlock_unlock(&vq->access_lock);
> + }
> }
> break;
> default:
> --
> 2.34.1
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
next prev parent reply other threads:[~2022-02-17 7:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 11:09 Maxime Coquelin
2022-02-17 7:32 ` Xia, Chenbo [this message]
2022-02-17 8:00 ` David Marchand
2022-02-17 8:55 ` Maxime Coquelin
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=SN6PR11MB350427A4DDE8AEC713AD71E99C369@SN6PR11MB3504.namprd11.prod.outlook.com \
--to=chenbo.xia@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
--cc=yuanx.wang@intel.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;
as well as URLs for NNTP newsgroup(s).