From: Wei Liu <wei.liu@kernel.org>
To: Andres Beltran <lkmlabelt@gmail.com>
Cc: Wei Liu <wei.liu@kernel.org>,
Andres Beltran <t-mabelt@microsoft.com>,
KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Kelley <mikelley@microsoft.com>,
Andrea Parri <parri.andrea@gmail.com>
Subject: Re: [PATCH v2 1/3] Drivers: hv: vmbus: Add vmbus_requestor data structure for VMBus hardening
Date: Tue, 30 Jun 2020 10:48:56 +0000 [thread overview]
Message-ID: <20200630104856.i3zwib2zrf644w6v@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <20200630101736.ggskutpgv36lr4q7@liuwe-devbox-debian-v2>
On Tue, Jun 30, 2020 at 10:17:36AM +0000, Wei Liu wrote:
[...]
> > >
> > > If the allocation of the requestor fails during runtime, vmbus_open()
> > > fails too and therefore,
> > > the channel and the requestor will not be created. So, the 2 functions
> > > (next_id, requestor_addr)
> > > will never get called, right? The only case in which we hit this edge
> > > case is if a driver is using this
> > > mechanism with a size of 0 (i.e. rqstor_size is not set to a non-zero
> > > value before calling vmbus_open()),
> >
> > Right. This is what I was getting at. Setting the size to 0 effectively
> > makes the driver unusable. And per your design, it should be considered
> > a bug.
> >
> > > but that would be more like a coding bug. So, I think it would be
> > > better to return VMBUS_RQST_ERROR
> > > as a way to assert that there is a bug in the code. I don't know if
> > > I'm missing something here.
> >
> > Since we know setting size to 0 is a bug, you can actually just do the
> > following in the __vmbus_open function instead of going through all the
> > initialization with the knowledge vmbus_next_request_id & co will fail.
> >
> > /* Create and init requestor */
> > if (!newchannel->rqstor_size)
> > return an error to caller here
> >
> > vmbus_alloc_requestor(...);
>
> And obviously you should check vmbus_alloc_requestor's return value
> somehow. You get the idea...
>
Andrea pointed out that I missed one critical aspect of the design --
not all drivers are supposed to use this infrastructure. That's contrary
to my original understanding, in which all drivers are supposed to use
this infrastructure.
With that in mind, it is okay to only initialize the infra only when
->rqstor_size is not zero. Then you just handle the edge case in
vmbus_next_request_id & co.
Wei.
> Wei.
>
> >
> >
> > Wei.
> >
> > >
> > > Andres.
next prev parent reply other threads:[~2020-06-30 10:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 20:02 [PATCH v2 0/3] Drivers: hv: vmbus: vmbus_requestor data structure for VMBus hardening Andres Beltran
2020-06-29 20:02 ` [PATCH v2 1/3] Drivers: hv: vmbus: Add " Andres Beltran
2020-06-29 20:46 ` Wei Liu
2020-06-29 21:51 ` Andres Beltran
2020-06-29 21:56 ` Michael Kelley
2020-06-29 22:09 ` Andres Beltran
2020-06-29 22:15 ` Wei Liu
2020-06-29 22:20 ` Wei Liu
2020-06-29 23:45 ` Andres Beltran
2020-06-30 10:09 ` Wei Liu
2020-06-30 10:17 ` Wei Liu
2020-06-30 10:48 ` Wei Liu [this message]
2020-06-29 20:02 ` [PATCH v2 2/3] scsi: storvsc: Use vmbus_requestor to generate transaction IDs " Andres Beltran
2020-06-29 20:02 ` [PATCH v2 3/3] hv_netvsc: " Andres Beltran
2020-06-29 21:33 ` Haiyang Zhang
2020-06-29 22:26 ` Wei Liu
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=20200630104856.i3zwib2zrf644w6v@liuwe-devbox-debian-v2 \
--to=wei.liu@kernel.org \
--cc=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=sthemmin@microsoft.com \
--cc=t-mabelt@microsoft.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