mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: "Stefano Stabellini" <stefano.stabellini@eu.citrix.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [Xen-devel] [PATCH 2/2] xen/blkfront: Add BUG_ON to deal with misbehaving backends.
Date: Tue, 29 May 2012 09:12:31 +0100	[thread overview]
Message-ID: <4FC4A10F0200007800086842@nat28.tlf.novell.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1205281111460.26786@kaball-desktop>

>>> On 28.05.12 at 12:18, Stefano Stabellini <stefano.stabellini@eu.citrix.com>
wrote:
> On Fri, 25 May 2012, Konrad Rzeszutek Wilk wrote:
>> Part of the ring structure is the 'id' field which is under
>> control of the frontend. The frontend stamps it with "some"
>> value (this some in this implementation being a value less
>> than BLK_RING_SIZE), and when it gets a response expects
>> said value to be in the response structure. We have a check
>> for the id field when spolling new requests but not when
>> de-spolling responses.
>> 
>> We also add an extra check in add_id_to_freelist to make
>> sure that the 'struct request' was not NULL - as we cannot
>> pass a NULL to __blk_end_request_all, otherwise that crashes
>> (and all the operations that the response is dealing with
>> end up with __blk_end_request_all).
>> 
>> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> ---
>>  drivers/block/xen-blkfront.c |    7 +++++++
>>  1 files changed, 7 insertions(+), 0 deletions(-)
>> 
>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>> index 60eed4b..8e177ca 100644
>> --- a/drivers/block/xen-blkfront.c
>> +++ b/drivers/block/xen-blkfront.c
>> @@ -145,6 +145,7 @@ static void add_id_to_freelist(struct blkfront_info 
> *info,
>>  			       unsigned long id)
>>  {
>>  	info->shadow[id].req.u.rw.id  = info->shadow_free;
>> +	BUG_ON(info->shadow[id].request == NULL);

This only catches a small sub-portion of possible bad backend
behavior. Checking (as the very first thing in the function) e.g.

info->shadow[id].req.u.rw.id == id

would seem to cover a broader set (based on my recent looking
at similar mismatches apparently resulting from the qdisk
backend occasionally sending bad/duplicate responses).

But take this with the below applied here too.

>>  	info->shadow[id].request = NULL;
>>  	info->shadow_free = id;
>>  }
>> @@ -746,6 +747,12 @@ static irqreturn_t blkif_interrupt(int irq, void 
> *dev_id)
>>  
>>  		bret = RING_GET_RESPONSE(&info->ring, i);
>>  		id   = bret->id;
>> +		/*
>> +		 * The backend has messed up and given us an id that we would
>> +		 * never have given to it (we stamp it up to BLK_RING_SIZE -
>> +		 * look in get_id_from_freelist.
>> +		 */
>> +		BUG_ON(id >= BLK_RING_SIZE);
>>  		req  = info->shadow[id].request;
>>  
>>  		if (bret->operation != BLKIF_OP_DISCARD)
> 
> While we should certainly check whether bret->id is valid before
> using it, is it actually correct that the frontend BUGs in response of a
> backend bug?
> 
> If the IO doesn't involve the root disk, the guest might be able to
> function correctly without communicating with the backend at all.
> I think we should WARN and return error. Maybe also call blkfront_remove
> if we can.

I very much agree to this.

Jan


  reply	other threads:[~2012-05-29  8:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25 21:50 [PATCH] fixes to xen-blk[back|front] to deal with 32/64 host/guest combination with BLKIF_DISCARD (v1) Konrad Rzeszutek Wilk
2012-05-25 21:50 ` [PATCH 1/2] xen/blkback: Copy id field when doing BLKIF_DISCARD Konrad Rzeszutek Wilk
2012-05-28 10:19   ` [Xen-devel] " Stefano Stabellini
2012-05-30 20:39     ` William Dauchy
2012-05-30 21:16       ` Konrad Rzeszutek Wilk
2012-05-25 21:50 ` [PATCH 2/2] xen/blkfront: Add BUG_ON to deal with misbehaving backends Konrad Rzeszutek Wilk
2012-05-28 10:18   ` [Xen-devel] " Stefano Stabellini
2012-05-29  8:12     ` Jan Beulich [this message]
2012-05-31 18:17       ` Konrad Rzeszutek Wilk
2012-06-01  7:44         ` Jan Beulich
2012-06-01 10:16         ` Stefano Stabellini
2012-06-07 21:59           ` Konrad Rzeszutek Wilk
2012-06-08  7:12             ` Jan Beulich
2012-06-11 18:22               ` Konrad Rzeszutek Wilk
2012-06-11 18:52                 ` Konrad Rzeszutek Wilk
2012-06-12  8:45                   ` Jan Beulich
2012-06-08 10:06             ` Stefano Stabellini

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=4FC4A10F0200007800086842@nat28.tlf.novell.com \
    --to=jbeulich@suse.com \
    --cc=axboe@kernel.dk \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.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

all inboxes | Powered by JetHome®