qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH RFC 1/7] virtio: relax feature check


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH RFC 1/7] virtio: relax feature check
Date: Tue, 12 May 2015 14:49:59 +0100

On 12 May 2015 at 14:14, Cornelia Huck <address@hidden> wrote:
> On Wed, 06 May 2015 14:07:37 +0200
> Greg Kurz <address@hidden> wrote:
>> @@ -233,7 +233,6 @@ static inline void virtio_clear_feature(uint32_t 
>> *features, unsigned int fbit)
>>
>>  static inline bool __virtio_has_feature(uint32_t features, unsigned int 
>> fbit)
>>  {
>> -    assert(fbit < 32);
>>      return !!(features & (1 << fbit));
>>  }
>>
>>
>>
>
> I must say I'm not very comfortable with knowingly passing out-of-rage
> values to this function.

It would invoke C undefined behaviour, so clearly a bug if we did
pass an out-of-range value here. You'd need to at least do
    if (fbit >= 32) {
        return false;
    }
if you want to make it valid.

-- PMM



reply via email to

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