Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161036AbbBCRp1 (ORCPT ); Tue, 3 Feb 2015 12:45:27 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:47179 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966495AbbBCRnz (ORCPT ); Tue, 3 Feb 2015 12:43:55 -0500 X-AuditID: cbfec7f5-b7fc86d0000066b7-c1-54d10846c391 From: Andrey Ryabinin To: linux-kernel@vger.kernel.org Cc: Andrey Ryabinin , 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, Rusty Russell Subject: [PATCH v11 18/19] module: fix types of device tables aliases Date: Tue, 03 Feb 2015 20:43:11 +0300 Message-id: <1422985392-28652-19-git-send-email-a.ryabinin@samsung.com> X-Mailer: git-send-email 2.2.2 In-reply-to: <1422985392-28652-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1422985392-28652-1-git-send-email-a.ryabinin@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xK7puHBdDDJoWiVls+/WIzeL33pms FnPWr2GzOHLtO7vF9W9vGC0+vXzAaPH84UN2iwkP29gtVnY3s1lsf/aWyWJl5wNWi8u75rBZ 3Fvzn9Xi5rQLLBaLj9xmtnj3bDKzxY8Nj1kdBD3m7/zI6LFz1l12jwWbSj0W73nJ5LFpVSeb x6ZPk9g9ut5eYfI4MeM3i8eTK9OZPD4+vcXisWLDCWaPvi2rGD0+b5IL4I3isklJzcksSy3S t0vgyvj5uoO9YDV/xeWDb5kaGF/xdDFyckgImEjcf72cEcIWk7hwbz1bFyMXh5DAUkaJHa9/ skI4fUwSx+auYAKpYhPQk/g3azsbiC0ioCCxufcZWBGzwHkWieeHjoMlhAVcJaY+egLWwCKg KtHzZyUziM0r4C7xdtsHIJsDaJ2cxIWP8SBhTqDwvv5njBDLmhgl3ixuYZ7AyLuAkWEVo2hq aXJBcVJ6rpFecWJucWleul5yfu4mRkgsfN3BuPSY1SFGAQ5GJR5ejXcXQoRYE8uKK3MPMUpw MCuJ8O75DRTiTUmsrEotyo8vKs1JLT7EyMTBKdXAaO9wlGtjQ9bGw8dF09Ke7FU7WbbLp9G7 TMhkvirnW1435imc/5a6XbTwlDpWtnJZd0nckn231gZ1OqW/8r07aWmHnmD+VK11Tos6LE87 Hp915oDhhfOcbPuXX/d+/3L6P+7Jnh6mD0xWrljE858x8Oh2dQ+buatuBP/WEJcr8mzasbrt XrnoOiWW4oxEQy3mouJEAKy4W1hjAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2162 Lines: 51 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. 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 to detect possible out of bounds accesses. When symbol has an alias __asan_register_globals() will be called as for symbol so for alias. Compiler determines size of variable by size of variable's type. Alias and symbol have the same address, so if alias have the wrong size part of memory that actually belongs to the symbol could be poisoned as redzone of alias symbol. By fixing type of alias symbol we will fix size of it, so __asan_register_globals() will not poison valid memory. Signed-off-by: Andrey Ryabinin --- include/linux/module.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/module.h b/include/linux/module.h index b653d7c..42999fe 100644 --- 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 const typeof(name) __mod_##type##__##name##_device_table \ __attribute__ ((unused, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) -- 2.2.2 -- 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/