Re: [PATCH] vhost: reject zero-size IOTLB INVALIDATE
Eugenio Perez Martin <[email protected]>
| Newsgroups | dev.linux.lists.virtualization,org.kernel.vger.kvm,org.kernel.vger.netdev |
|---|---|
| Message-ID | <CAJaqyWfW9n5o+ojrEjK-m+6cwH_TSxWckjkvEXowZA8r=vDmdQ@mail.gmail.com> |
On Thu, Jul 16, 2026 at 5:02 AM Weimin Xiong <[email protected]> wrote: > > From: xiongweimin <[email protected]> > > Reject VHOST_IOTLB_INVALIDATE messages with size == 0 to prevent > iova + size - 1 from underflowing to U64_MAX, which would > incorrectly delete the entire IOTLB. > > Signed-off-by: xiongweimin <[email protected]> > --- > drivers/vhost/vhost.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index 3c080c454e374cabd7321416ed92c5f7d3135254..xxxxxxxxxx 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -1656,6 +1656,10 @@ static int vhost_process_iotlb_msg(struct vhost_dev *dev, u32 asid, > if (!dev->iotlb) { > ret = -EFAULT; > break; > + } > + if (!msg->size) { > + ret = -EINVAL; > + break; > } I think the issue is real, but how about adding the condition to the caller vhost_chr_write_iter? It is already the if (msg.type == VHOST_IOTLB_UPDATE && msg.size == 0) { ret = -EINVAL; goto done; } So it should be somthing in the line of: if ((msg.type == VHOST_IOTLB_UPDATE || msg.type == VHOST_IOTLB_INVALIDATE) && msg.size == 0) { ret = -EINVAL; goto done; } With that, please add my acked-by. > vhost_vq_meta_reset(dev); > vhost_iotlb_del_range(dev->iotlb, msg->iova, > -- > 2.39.3 >