is __asan_loadN_noabort() the same as __asan_loadN()?

116 views
Skip to first unread message

Xishi Qiu

unread,
Apr 19, 2016, 5:20:01 AM4/19/16
to Andrey Ryabinin, kasan-dev, Xishi Qiu
Hi,

Where does this function defined? __asan_loadN_noabort()
Is __asan_loadN_noabort() the same as __asan_loadN()?

...
void __asan_loadN(unsigned long addr, size_t size)
{
check_memory_region(addr, size, false);
}
EXPORT_SYMBOL(__asan_loadN);

__alias(__asan_loadN)
void __asan_loadN_noabort(unsigned long, size_t);
EXPORT_SYMBOL(__asan_loadN_noabort);
...

Thanks,
Xishi Qiu

Dmitry Vyukov

unread,
Apr 19, 2016, 5:34:03 AM4/19/16
to Xishi Qiu, Andrey Ryabinin, kasan-dev
Hi Xishi,

__asan_loadN_noabort is not defined, it is aliased to __asan_loadN. It
means that both symbols point to the same contents.

__asan_loadN_noabort and __asan_loadN are the same code-wise, but
compiler treats _noabort version as, well, noabort (can return, while
__asan_loadN must not return).

Andrey Ryabinin

unread,
Apr 19, 2016, 5:40:26 AM4/19/16
to Dmitry Vyukov, Xishi Qiu, kasan-dev
That matters only for user space. For kernel the only difference is that
gcc >= 5 always generate only _noabort calls, and gcc >= 4.9.2 always generate only __asan_loadN calls.

Xishi Qiu

unread,
Apr 19, 2016, 6:24:09 AM4/19/16
to Andrey Ryabinin, Dmitry Vyukov, kasan-dev
On 2016/4/19 17:40, Andrey Ryabinin wrote:

>
>
> On 04/19/2016 12:33 PM, Dmitry Vyukov wrote:
>> On Tue, Apr 19, 2016 at 11:19 AM, Xishi Qiu <qiux...@huawei.com> wrote:
>>> Hi,
>>>
>>> Where does this function defined? __asan_loadN_noabort()
>>> Is __asan_loadN_noabort() the same as __asan_loadN()?
>>>
>>> ...
>>> void __asan_loadN(unsigned long addr, size_t size)
>>> {
>>> check_memory_region(addr, size, false);
>>> }
>>> EXPORT_SYMBOL(__asan_loadN);
>>>
>>> __alias(__asan_loadN)
>>> void __asan_loadN_noabort(unsigned long, size_t);
>>> EXPORT_SYMBOL(__asan_loadN_noabort);
>>> ...
>>
>>
>> Hi Xishi,
>>
>> __asan_loadN_noabort is not defined, it is aliased to __asan_loadN. It
>> means that both symbols point to the same contents.
>>
>> __asan_loadN_noabort and __asan_loadN are the same code-wise, but
>> compiler treats _noabort version as, well, noabort (can return, while
>> __asan_loadN must not return).
>

Hi, what does return mean? The two functions are both "void".

Thanks,
Xishi Qiu

Dmitry Vyukov

unread,
Apr 19, 2016, 6:29:54 AM4/19/16
to Xishi Qiu, Andrey Ryabinin, kasan-dev
On Tue, Apr 19, 2016 at 12:23 PM, Xishi Qiu <qiux...@huawei.com> wrote:
> On 2016/4/19 17:40, Andrey Ryabinin wrote:
>
>>
>>
>> On 04/19/2016 12:33 PM, Dmitry Vyukov wrote:
>>> On Tue, Apr 19, 2016 at 11:19 AM, Xishi Qiu <qiux...@huawei.com> wrote:
>>>> Hi,
>>>>
>>>> Where does this function defined? __asan_loadN_noabort()
>>>> Is __asan_loadN_noabort() the same as __asan_loadN()?
>>>>
>>>> ...
>>>> void __asan_loadN(unsigned long addr, size_t size)
>>>> {
>>>> check_memory_region(addr, size, false);
>>>> }
>>>> EXPORT_SYMBOL(__asan_loadN);
>>>>
>>>> __alias(__asan_loadN)
>>>> void __asan_loadN_noabort(unsigned long, size_t);
>>>> EXPORT_SYMBOL(__asan_loadN_noabort);
>>>> ...
>>>
>>>
>>> Hi Xishi,
>>>
>>> __asan_loadN_noabort is not defined, it is aliased to __asan_loadN. It
>>> means that both symbols point to the same contents.
>>>
>>> __asan_loadN_noabort and __asan_loadN are the same code-wise, but
>>> compiler treats _noabort version as, well, noabort (can return, while
>>> __asan_loadN must not return).
>>
>
> Hi, what does return mean? The two functions are both "void".


Void functions can also return. But functions like exit or abort do
not return, and they are treated specially by compilers. __asan_loadN
is like exit -- it does not return. __asan_loadN_noabort is like a
normal function -- it can return.

Andrey Ryabinin

unread,
Apr 19, 2016, 6:55:14 AM4/19/16
to Dmitry Vyukov, Xishi Qiu, kasan-dev
That's not what noabort means here. Both __asan_load()/__asan_load_noabort() can return.
The difference is that if asan hits a bug __asan_load() will not return, while __asan_load_noabort()
in that case will return.

But, again, that difference is about userspace ASan only. This controlled by -fsanitize-recover gcc flag.
-fsanitize-recover exists since gcc>=5 and always enabled for KASAN. So gcc5 always generate kernel with __asan_load_noabort() calls only.
gcc4.9 doesn't have fsanitize-recover, so it always generate kernel with __asan_load() calls only.




Reply all
Reply to author
Forward
0 new messages