qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Lieven <pl@kamp.de>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
	qemu-stable@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH] block/iscsi: avoid data corruption with cache=writeback
Date: Tue, 17 Jan 2017 12:31:56 +0100	[thread overview]
Message-ID: <06840643-1e3d-b60b-95c1-6e28c441aa1e@kamp.de> (raw)
In-Reply-To: <20170117112848.GB6199@lemon>

Am 17.01.2017 um 12:28 schrieb Fam Zheng:
> On Mon, 01/16 16:17, Peter Lieven wrote:
>> nb_cls_shrunk in iscsi_allocmap_update can become -1 if the
>> request starts and ends within the same cluster. This results
>> in passing -1 to bitmap_set and bitmap_clear and they don't
>> handle negative values properly. In the end this leads to data
>> corruption.
>>
>> Fixes: e1123a3b40a1a9a625a29c8ed4debb7e206ea690
>> Cc: qemu-stable@nongnu.org
>> Signed-off-by: Peter Lieven <pl@kamp.de>
>> ---
>>   block/iscsi.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/iscsi.c b/block/iscsi.c
>> index 6aeeb9e..1860f1b 100644
>> --- a/block/iscsi.c
>> +++ b/block/iscsi.c
>> @@ -499,14 +499,18 @@ iscsi_allocmap_update(IscsiLun *iscsilun, int64_t sector_num,
>>       if (allocated) {
>>           bitmap_set(iscsilun->allocmap, cl_num_expanded, nb_cls_expanded);
>>       } else {
>> -        bitmap_clear(iscsilun->allocmap, cl_num_shrunk, nb_cls_shrunk);
>> +        if (nb_cls_shrunk > 0) {
>> +            bitmap_clear(iscsilun->allocmap, cl_num_shrunk, nb_cls_shrunk);
>> +        }
>>       }
>>   
>>       if (iscsilun->allocmap_valid == NULL) {
>>           return;
>>       }
>>       if (valid) {
>> -        bitmap_set(iscsilun->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);
>> +        if (nb_cls_shrunk > 0) {
>> +            bitmap_set(iscsilun->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);
>> +        }
>>       } else {
>>           bitmap_clear(iscsilun->allocmap_valid, cl_num_expanded,
>>                        nb_cls_expanded);
>> -- 
>> 1.9.1
>>
>>
> It's probably a good idea to add assertions parameter in bitmap_*.

yes, i will send a follow-up patch.

Peter

  reply	other threads:[~2017-01-17 11:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 15:17 [Qemu-devel] [PATCH] block/iscsi: avoid data corruption with cache=writeback Peter Lieven
2017-01-17 11:28 ` [Qemu-devel] [Qemu-stable] " Fam Zheng
2017-01-17 11:31   ` Peter Lieven [this message]
2017-01-20 16:45 ` [Qemu-devel] " Paolo Bonzini

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=06840643-1e3d-b60b-95c1-6e28c441aa1e@kamp.de \
    --to=pl@kamp.de \
    --cc=famz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.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).