qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 7/6] nbd/client: Ignore inaccessible tail of


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 7/6] nbd/client: Ignore inaccessible tail of inconsistent server
Date: Fri, 29 Mar 2019 15:28:40 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0

On 3/29/19 11:54 AM, Vladimir Sementsov-Ogievskiy wrote:
> 29.03.2019 19:34, Eric Blake wrote:
>> The NBD spec suggests that a server should never advertise a size
>> inconsistent with its minimum block alignment, as that tail is
>> effectively inaccessible to a compliant client obeying those block
>> constraints. Although the block layer likes to round up, here, we'd
>> prefer to truncate down to obey the spec, and note that it is the
>> server's fault for advertising bogus size.
>>
>> Does not impact either qemu (which always sends properly aligned
>> sizes) or nbdkit (which does not send minimum block requirements yet);
>> so this is mostly theoretical, to avoid potential asserts elsewhere in
>> the code that assume the size is aligned.
>>

>>               }
>> +            if (info->min_block &&
>> +                !QEMU_IS_ALIGNED(info->size, info->min_block)) {
>> +                trace_nbd_opt_info_go_unaligned_size(info->size,
>> +                                                     info->min_block);
>> +                info->size = QEMU_ALIGN_DOWN(info->size, info->min_block);
>> +            }
>>               trace_nbd_receive_negotiate_size_flags(info->size, 
>> info->flags);

> 
> And this again leads to silently skip file tail on qemu-img convert from such 
> nbd export.
> I don't really care, but if not Qemu neither nbdkit are affected, isn't it 
> better just
> nbd_send_opt_abort and return -1 in this case? So we'll never have hidden 
> troubles with
> third-party bad servers, and their developers will have to fix their code 
> instead (even
> not written yet, I suppose).

The code below is an example of killing connection to an impossible server:

            if (!is_power_of_2(info->min_block)) {
                error_setg(errp, "server minimum block size %" PRIu32
                           " is not a power of two", info->min_block);
                nbd_send_opt_abort(ioc);
                return -1;

I'll copy that instead of silently truncating and proceeding on.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]