[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <54E1F834.4000408@samsung.com>
Date: Mon, 16 Feb 2015 17:01:24 +0300
From: Andrey Ryabinin <a.ryabinin@...sung.com>
To: Rusty Russell <rusty@...tcorp.com.au>, linux-kernel@...r.kernel.org
Cc: Dmitry Vyukov <dvyukov@...gle.com>,
Konstantin Serebryany <kcc@...gle.com>,
Dmitry Chernenkov <dmitryc@...gle.com>,
Andrey Konovalov <adech.fo@...il.com>,
Yuri Gribov <tetra2005@...il.com>,
Konstantin Khlebnikov <koct9i@...il.com>,
Sasha Levin <sasha.levin@...cle.com>,
Christoph Lameter <cl@...ux.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Dave Hansen <dave.hansen@...el.com>,
Andi Kleen <andi@...stfloor.org>, x86@...nel.org,
linux-mm@...ck.org
Subject: Re: [PATCH v11 18/19] module: fix types of device tables aliases
On 02/16/2015 05:44 AM, Rusty Russell wrote:
> Andrey Ryabinin <a.ryabinin@...sung.com> writes:
>> 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.
>
> Hmm, as Andrew Morton points out, this breaks some usage; if we just
> fix the type (struct type##_device_id[]) will that work instead?
>
> I'm guessing not, since typeof(x) will presumably preserve sizing
> information?
>
Yes, this won't work.
In this particular case 'struct type##_device_id[]' would be equivalent
to 'struct type##_device_id[1]'
$ cat test.c
struct d {
int a;
int b;
};
struct d arr[] = {
{1, 2}, {3, 4}, {}
};
extern struct d arr_alias[] __attribute__((alias("arr")));
$ gcc -c test.c
test.c:8:17: warning: array ‘arr_alias’ assumed to have one element
extern struct d arr_alias[] __attribute__((alias("arr")));
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists