[PATCH] vhost: fix offset while mmaping log base address
BillXiang
xiangwencheng at dayudpu.com
Wed Jul 10 05:22:58 CEST 2024
From: BillXiang <xiangwencheng at dayudpu.com>
> From: "Chenbo Xia"<chenbox at nvidia.com>
> Date: Tue, Jul 9, 2024, 20:42
> Subject: Re: [PATCH] vhost: fix offset while mmaping log base address
> To: "BillXiang"<xiangwencheng at dayudpu.com>
> Cc: "Maxime Coquelin"<maxime.coquelin at redhat.com>, "Jianfeng Tan"<jianfeng.tan at intel.com>, "Tomasz Kulasek"<tomaszx.kulasek at intel.com>, "Pawel Wodkowski"<pawelx.wodkowski at intel.com>, "dev at dpdk.org"<dev at dpdk.org>
> > On Jul 8, 2024, at 14:57, BillXiang <xiangwencheng at dayudpu.com> wrote:
> >
> > External email: Use caution opening links or attachments
> >
> >
> > From: BillXiang <xiangwencheng at dayudpu.com>
> >
> > For sanity the offset should be the last parameter of mmap.
> >
> > Fixes: fbc4d24 ("vhost: fix offset while mmaping log base address")
>
> The commit id length should be 12.
>
Thanks, I will mind it.
> Since QEMU always send offset 0, I think it's no need to backport the
> patch, so no cc-stable is fine.
>
I just think the code is confusing and I'm wondering whether the offset
sent by QEMU or maybe other VM can be non-zero.
If it's a mistake just fix it.
> With above fixed:
>
> Reviewed-by: Chenbo Xia <chenbox at nvidia.com>
>
> > Signed-off-by: BillXiang <xiangwencheng at dayudpu.com>
> > ---
> > lib/vhost/vhost_user.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> > index 5f470da38a..0893ae80bb 100644
> > --- a/lib/vhost/vhost_user.c
> > +++ b/lib/vhost/vhost_user.c
> > @@ -2399,7 +2399,7 @@ vhost_user_set_log_base(struct virtio_net **pdev,
> > * mmap from 0 to workaround a hugepage mmap bug: mmap will
> > * fail when offset is not page size aligned.
> > */
> > - addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> > + addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, off);
> > alignment = get_blk_size(fd);
> > close(fd);
> > if (addr == MAP_FAILED) {
> > --
> > 2.30.0
More information about the dev
mailing list