qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-block] Guest unresponsive after Virtqueue size ex


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [Qemu-block] Guest unresponsive after Virtqueue size exceeded error
Date: Tue, 26 Feb 2019 14:30:09 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 23/02/19 12:49, Natanael Copa wrote:
> I suspect this happens due to the Alpine toolchain will enable
> _FORTIFY_SOURCE=2 by default and the way this is implemented via 
> fortify-headers:
> http://git.2f30.org/fortify-headers/file/include/string.h.html#l39

The call to __orig_memcpy is the culprit there, is there any reason not
to do something like

_FORTIFY_FN(memcpy)
void *__memcpy_chk(void *__od, const void *__os, size_t __n)
{
        size_t __bd = __builtin_object_size(__od, 0);
        size_t __bs = __builtin_object_size(__os, 0);
        char *__d = (char *)__od;
        const char *__s = (const char *)__os;

        /* trap if pointers are overlapping but not if dst == src.
         * gcc seems to like to generate code that relies on dst == src */
        if ((__d < __s && __d + __n > __s) ||
            (__s < __d && __s + __n > __d))
                __builtin_trap();
        if (__n > __bd || __n > __bs)
                __builtin_trap();
        return memcpy(__od, __os, __n);
}
#define memcpy __memcpy_chk

?  That is, getting rid of _FORTIFY_ORIG altogether.

Paolo



reply via email to

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