From: Wei Liu <wei.liu@kernel.org>
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Yanming Liu <yanminglr@gmail.com>,
linux-hyperv@vger.kernel.org, Wei Liu <wei.liu@kernel.org>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-fbdev@vger.kernel.org, kys@microsoft.com,
haiyangz@microsoft.com, sthemmin@microsoft.com,
decui@microsoft.com, drawat.floss@gmail.com, airlied@linux.ie,
daniel@ffwll.ch, mikelley@microsoft.com, lkmlabelt@gmail.com
Subject: Re: [PATCH v2] hv: account for packet descriptor in maximum packet size
Date: Fri, 14 Jan 2022 19:13:07 +0000 [thread overview]
Message-ID: <20220114191307.uu2oel7wbxhiqe56@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <20220110004419.GA435914@anparri>
On Mon, Jan 10, 2022 at 01:44:19AM +0100, Andrea Parri wrote:
> (Extending Cc: list,)
>
> On Sun, Jan 09, 2022 at 05:55:16PM +0800, Yanming Liu wrote:
> > Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V
> > out of the ring buffer") introduced a notion of maximum packet size in
> > vmbus channel and used that size to initialize a buffer holding all
> > incoming packet along with their vmbus packet header. Currently, some
> > vmbus drivers set max_pkt_size to the size of their receive buffer
> > passed to vmbus_recvpacket, however vmbus_open expects this size to also
> > include vmbus packet header. This leads to corruption of the ring buffer
> > state when receiving a maximum sized packet.
> >
> > Specifically, in hv_balloon I have observed of a dm_unballoon_request
> > message of 4096 bytes being truncated to 4080 bytes. When the driver
> > tries to read next packet it starts from a wrong read_index, receives
> > garbage and prints a lot of "Unhandled message: type: <garbage>" in
> > dmesg.
> >
> > The same mismatch also happens in hv_fcopy, hv_kvp, hv_snapshot,
> > hv_util, hyperv_drm and hyperv_fb, though bad cases are not observed
> > yet.
> >
> > Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for
> > the descriptor, assuming the vmbus packet header will never be larger
> > than HV_HYP_PAGE_SIZE. This is essentially free compared to just adding
> > 'sizeof(struct vmpacket_descriptor)' because these buffers are all more
> > than HV_HYP_PAGE_SIZE bytes so kmalloc rounds them up anyway.
> >
> > Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
> > Suggested-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
> > Signed-off-by: Yanming Liu <yanminglr@gmail.com>
>
> Thanks for sorting this out; the patch looks good to me:
>
> Reviewed-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
>
Thanks. I will pick this up after 5.17-rc1 is out.
Wei.
next prev parent reply other threads:[~2022-01-14 19:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220109095516.3250392-1-yanminglr@gmail.com>
2022-01-10 0:44 ` [PATCH v2] hv: account for packet descriptor in maximum packet size Andrea Parri
2022-01-14 19:13 ` Wei Liu [this message]
2022-01-19 18:12 ` Michael Kelley (LINUX)
2022-01-19 20:13 ` Yanming Liu
2022-01-27 21:22 ` Michael Kelley (LINUX)
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=20220114191307.uu2oel7wbxhiqe56@liuwe-devbox-debian-v2 \
--to=wei.liu@kernel.org \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=decui@microsoft.com \
--cc=drawat.floss@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkmlabelt@gmail.com \
--cc=mikelley@microsoft.com \
--cc=parri.andrea@gmail.com \
--cc=sthemmin@microsoft.com \
--cc=yanminglr@gmail.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).