linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Haiyang Zhang <haiyangz@microsoft.com>
To: Andres Beltran <lkmlabelt@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Cc: KY Srinivasan <kys@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Michael Kelley <mikelley@microsoft.com>,
	Andrea Parri <parri.andrea@gmail.com>,
	Saruhan Karademir <skarade@microsoft.com>
Subject: RE: [PATCH] Drivers: hv: vmbus: Fix variable assignments in hv_ringbuffer_read()
Date: Sun, 26 Jul 2020 23:53:10 +0000	[thread overview]
Message-ID: <BL0PR2101MB0930440E86045F954B6118B2CA750@BL0PR2101MB0930.namprd21.prod.outlook.com> (raw)
In-Reply-To: <CAGpZZ6ugh-SprR=oMkktEVuEJvNrK06TLqgskey0JkCdZCmvMA@mail.gmail.com>



> -----Original Message-----
> From: Andres Beltran <lkmlabelt@gmail.com>
> Sent: Friday, July 24, 2020 7:04 PM
> To: Stephen Hemminger <stephen@networkplumber.org>
> Cc: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>;
> Wei Liu <wei.liu@kernel.org>; linux-hyperv@vger.kernel.org; linux-
> kernel@vger.kernel.org; Michael Kelley <mikelley@microsoft.com>; Andrea
> Parri <parri.andrea@gmail.com>; Saruhan Karademir
> <skarade@microsoft.com>
> Subject: Re: [PATCH] Drivers: hv: vmbus: Fix variable assignments in
> hv_ringbuffer_read()
> 
> On Fri, Jul 24, 2020 at 1:10 PM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> > What is the rationale for this change, it may break other code.
> >
> > A common API model in Windows world where this originated
> > is to have a call where caller first
> > makes request and then if the requested buffer is not big enough the
> > caller look at the actual length and allocate a bigger buffer.
> >
> > Did you audit all the users of this API to make sure they aren't doing that.
> >
> 
> The rationale for the change was to solve instances like the one
> @Haiyang Zhang pointed out, especially in hv_utils, which needs
> additional hardening. Unfortunately, there is an instance in
> hv_pci_onchannelcallback() that does what you just described. Thus,
> the fix will have to be made to all the callers of vmbus_recvpacket()
> and vmbus_recvpacket_raw() to make sure they check the return value,
> which most callers are not doing now. Thanks for pointing out this
> behavior. I was not aware that the length can be checked by callers to
> allocate a bigger buffer.

To prevent future coding error, please add code comments for 
hv_ringbuffer_read() to indicate that the buffer_actual_len may be 
nonzero when the function fails, and should not be used to 
determine if the function succeeds or not.

Thanks,
- Haiyang


      reply	other threads:[~2020-07-26 23:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 16:46 [PATCH] Drivers: hv: vmbus: Fix variable assignments in hv_ringbuffer_read() Andres Beltran
2020-07-24 17:10 ` Stephen Hemminger
2020-07-24 17:48   ` Haiyang Zhang
2020-07-24 23:04   ` Andres Beltran
2020-07-26 23:53     ` Haiyang Zhang [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=BL0PR2101MB0930440E86045F954B6118B2CA750@BL0PR2101MB0930.namprd21.prod.outlook.com \
    --to=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --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=skarade@microsoft.com \
    --cc=stephen@networkplumber.org \
    --cc=sthemmin@microsoft.com \
    --cc=wei.liu@kernel.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).