linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anirudh Rayabharam <mail@anirudhrb.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	syzbot+0abd373e2e50d704db87@syzkaller.appspotmail.com,
	kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost: handle zero regions in vhost_set_memory
Date: Tue, 22 Feb 2022 01:27:35 +0530	[thread overview]
Message-ID: <YhPur8ymuiiHirUc@anirudhrb.com> (raw)
In-Reply-To: <20220221164817.obpw477w74auxlkn@sgarzare-redhat>

On Mon, Feb 21, 2022 at 05:48:17PM +0100, Stefano Garzarella wrote:
> On Mon, Feb 21, 2022 at 12:58:51PM +0530, Anirudh Rayabharam wrote:
> > Return early when userspace sends zero regions in the VHOST_SET_MEM_TABLE
> > ioctl.
> > 
> > Otherwise, this causes an erroneous entry to be added to the iotlb. This
> > entry has a range size of 0 (due to u64 overflow). This then causes
> > iotlb_access_ok() to loop indefinitely resulting in a hung thread.
> > Syzbot has reported this here:
> > 
> > https://syzkaller.appspot.com/bug?extid=0abd373e2e50d704db87
> 
> IIUC vhost_iotlb_add_range() in the for loop is never called if mem.nregions
> is 0, so I'm not sure the problem reported by syzbot is related.
> 
> In any case maybe this patch is fine, but currently I think we're just
> registering an iotlb without any regions, which in theory shouldn't cause
> any problems.

Sent a new patch: https://lore.kernel.org/lkml/20220221195303.13560-1-mail@anirudhrb.com/T/#u

> 
> Thanks,
> Stefano
> 
> > 
> > Reported-and-tested-by: syzbot+0abd373e2e50d704db87@syzkaller.appspotmail.com
> > Signed-off-by: Anirudh Rayabharam <mail@anirudhrb.com>
> > ---
> > drivers/vhost/vhost.c | 2 ++
> > 1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> > index 59edb5a1ffe2..821aba60eac2 100644
> > --- a/drivers/vhost/vhost.c
> > +++ b/drivers/vhost/vhost.c
> > @@ -1428,6 +1428,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
> > 		return -EFAULT;
> > 	if (mem.padding)
> > 		return -EOPNOTSUPP;
> > +	if (mem.nregions == 0)
> > +		return 0;
> > 	if (mem.nregions > max_mem_regions)
> > 		return -E2BIG;
> > 	newmem = kvzalloc(struct_size(newmem, regions, mem.nregions),
> > -- 
> > 2.35.1
> > 
> 

      parent reply	other threads:[~2022-02-21 19:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21  7:28 [PATCH] vhost: handle zero regions in vhost_set_memory Anirudh Rayabharam
2022-02-21  7:56 ` Jason Wang
2022-02-21  8:11   ` Anirudh Rayabharam
2022-02-21 16:48 ` Stefano Garzarella
2022-02-21 17:59   ` Anirudh Rayabharam
2022-02-21 19:57   ` Anirudh Rayabharam [this message]

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=YhPur8ymuiiHirUc@anirudhrb.com \
    --to=mail@anirudhrb.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sgarzare@redhat.com \
    --cc=syzbot+0abd373e2e50d704db87@syzkaller.appspotmail.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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).