lkml.org 
[lkml]   [2015]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v10 16/17] module: fix types of device tables aliases
On 01/30/2015 02:13 AM, Andrew Morton wrote:
> On Thu, 29 Jan 2015 18:12:00 +0300 Andrey Ryabinin <a.ryabinin@samsung.com> wrote:
>
>> MODULE_DEVICE_TABLE() macro used to create aliases to device tables.
>> Normally alias should have the same type as aliased symbol.
>>
>> Device tables are arrays, so they have 'struct type##_device_id[x]'
>> types. Alias created by MODULE_DEVICE_TABLE() will have non-array type -
>> 'struct type##_device_id'.
>>
>> This inconsistency confuses compiler, it could make a wrong
>> assumption about variable's size which leads KASan to
>> produce a false positive report about out of bounds access.
>
> The changelog describes the problem but doesn't describe how the patch
> addresses the problem. Some more details would be useful.
>

For every global variable compiler calls __asan_register_globals()
passing information about global variable (address, size, size with redzone, name ...)
__asan_register_globals() poison symbols redzone so we could detect out of bounds access.

If we have alias to symbol __asan_register_globals() will be called as for symbol so for alias.
Compiler determines size of variable by its type.
Alias and symbol have the same address, but if alias have the wrong size we will
poison part of memory that actually belongs to the symbol, not the redzone.


>> --- a/include/linux/module.h
>> +++ b/include/linux/module.h
>> @@ -135,7 +135,7 @@ void trim_init_extable(struct module *m);
>> #ifdef MODULE
>> /* Creates an alias so file2alias.c can find device table. */
>> #define MODULE_DEVICE_TABLE(type, name) \
>> - extern const struct type##_device_id __mod_##type##__##name##_device_table \
>> +extern typeof(name) __mod_##type##__##name##_device_table \
>> __attribute__ ((unused, alias(__stringify(name))))
>
> We lost the const? If that's deliberate then why? What are the
> implications? Do the device tables now go into rw memory?
>

Lack of const is unintentional, but this should be harmless because
this is just an alias to device table.

I'll add const back.


\
 
 \ /
  Last update: 2015-01-30 19:01    [W:0.196 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site