Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755795AbbBPOBa (ORCPT ); Mon, 16 Feb 2015 09:01:30 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:57782 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755562AbbBPOB3 (ORCPT ); Mon, 16 Feb 2015 09:01:29 -0500 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 X-AuditID: cbfec7f4-b7f126d000001e9a-ec-54e1f7a533f4 Content-transfer-encoding: 8BIT Message-id: <54E1F834.4000408@samsung.com> Date: Mon, 16 Feb 2015 17:01:24 +0300 From: Andrey Ryabinin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 To: Rusty Russell , linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Andrew Morton , Dave Hansen , Andi Kleen , x86@kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v11 18/19] module: fix types of device tables aliases References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1422985392-28652-1-git-send-email-a.ryabinin@samsung.com> <1422985392-28652-19-git-send-email-a.ryabinin@samsung.com> <87d25aa83x.fsf@rustcorp.com.au> In-reply-to: <87d25aa83x.fsf@rustcorp.com.au> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e/4Nd2l3x+GGDybIG3xe+9MVos569ew WRy59p3d4vq3N4wWn14+YLR4/vAhu8WEh23sFiu7m9kstj97y2SxsvMBq8XlXXPYLO6t+c9q cXPaBRaLxUduM1u8ezaZ2eLHhsesDgIe83d+ZPTYOesuu8eCTaUei/e8ZPLYtKqTzWPTp0ns Hl1vrzB5nJjxm8XjyZXpTB4fn95i8Vix4QSzx+dNcgE8UVw2Kak5mWWpRfp2CVwZ055+Yi+Y y1Wx68wi9gbGmRxdjJwcEgImEscXfWODsMUkLtxbD2RzcQgJLGWU+L/nGDtIgldAUOLH5Hss XYwcHMwC8hJHLmVDmOoSU6bkQpQ3M0n0Pp/CCFGuJfF68y6wVhYBVYk3z/aC2WwCehL/Zm0H 2yUqECEx/9hrZhBbRMBd4nbjCmaQQcwCf5glevp/M4EkhAU8JR5M2ckCseExo8T1NQvBujkF dCVatj9jmcAoMAvJfbMQ7puFcN8CRuZVjKKppckFxUnpuYZ6xYm5xaV56XrJ+bmbGCER+GUH 4+JjVocYBTgYlXh4N4Q9CBFiTSwrrsw9xCjBwawkwrvs/cMQId6UxMqq1KL8+KLSnNTiQ4xM HJxSDYzqOzZqT83zk7vzdv8fdQ4V48AMkZbcfVPnNV3S15iyYHEnp/HXefO0f/bXC+5Mn6Tc ybde8JLvqgAGk2MzTnpc2bLzyKvLhsbikTzLZbe0WN6z1p5U+u1s65TY2PPyuXuWBWp3lt11 ThffreicFj/rnv5js31SB3vqt8z9cLV+t8xJXq29JyuVWIozEg21mIuKEwGDDBt5ngIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1516 Lines: 43 On 02/16/2015 05:44 AM, Rusty Russell wrote: > Andrey Ryabinin 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/