From patchwork Fri May 5 19:46:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 98739 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp392151obb; Fri, 5 May 2017 12:52:47 -0700 (PDT) X-Received: by 10.98.201.197 with SMTP id l66mr11144662pfk.249.1494013795013; Fri, 05 May 2017 12:49:55 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si2689373pgp.198.2017.05.05.12.49.54; Fri, 05 May 2017 12:49:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754341AbdEETto (ORCPT + 6 others); Fri, 5 May 2017 15:49:44 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:58943 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756060AbdEETtl (ORCPT ); Fri, 5 May 2017 15:49:41 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lc3CH-1dnnFc2KE1-00jdAe; Fri, 05 May 2017 21:48:01 +0200 From: Arnd Bergmann To: Ben Hutchings Cc: stable@vger.kernel.org, Andrey Ryabinin , Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Dave Hansen , Andi Kleen , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Pekka Enberg , David Rientjes , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Arnd Bergmann Subject: [PATCH 3.16-stable 05/87] module: fix types of device tables aliases Date: Fri, 5 May 2017 21:46:23 +0200 Message-Id: <20170505194745.3627137-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170505194745.3627137-1-arnd@arndb.de> References: <20170505194745.3627137-1-arnd@arndb.de> X-Provags-ID: V03:K0:H84WldReHPBoBYRNr5BWq6NnjGpZtTewXDCic8kMnzIJEr51wUM 9LwjHRYvHCW+Gvq2cbbK7lpcboKchJR/972hlTS9O/j9Apxc/j62vrMLBNAkeffkjpFxZ3y okO3SyonS5Dwp99sQR7/W4VdG0mispluOdF1xkh4dls9G1OOW0mFIQgt5RnQfoq3ypwiOU/ fWtiGSiqnJLujh/j8QqwA== X-UI-Out-Filterresults: notjunk:1; V01:K0:t30vJNQofeI=:QhXjLaOd4Y5mDWo5hzr03L lisvjy3rR4YIX5H4pWDWHslROLkpnULU+k+iC2mP5OMmrW8w7H+eo17qP1l1IZwE4wFHSFCzA MIYuXAUeOdmPgasRDn59UtFprVxMYF4qhmxHmJ7MgRc7XXppqpW8aGf0JyaoppHuFNjYj0jTy a6T29jDCaMyKRw1qI0/GHjDwJzRTIjuLzhhHSE4lF86HFGc6o9Huf9KkQo+OmL/gReuA9AZWv wqgItgnlDRTgw+dfu7p0ZmLs0a7riASjSUCSRedRyMFwqM6em1UF9sjKEVDTtDTQvz4QduEML B6b0UolxBD/t2TS7iFe6YmxCF7fMDFfY7QgItlklsq9dPVKY1FF5eYgzTt0Cqrefhf5aOQo6y b7alIz+wg/Fi+Q/VbQzZHVZv8CWv7e3pYz1d2tnkukOAemRuy0A+9wxIm4Vn+xgtsuMJ9+99+ Lf/Iohwnki0TUdUy4ABm7GWjWEbJKmSf4jnlZnZsXYvkpoFnBy0SDMqjXBxyHyk2RgiiSmgaY YjaICZZTrGHYYO8kZK68UWL4zhg81wAHb4f8MGwustXENbHseJ5sw2F1gAhI2JyOkzDTiAHrX TaDQmMuzit3/5MmR7+USJh7HOrpFjvPLTkF58UJGPCSoAgOGIkAuzTbu3fjYXzXxVKSF5r1Ba 1kFoS+tv3vOmoWksd2zkBncBI+0mT7t6tB23J712c/NLkxMKi0NX9oIp4Ne8PVfRK4SE= Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Andrey Ryabinin commit 6301939d97d079f0d3dbe71e750f4daf5d39fc33 upstream. 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 Cc: Dmitry Vyukov Cc: Konstantin Serebryany Cc: Dmitry Chernenkov Signed-off-by: Andrey Konovalov Cc: Yuri Gribov Cc: Konstantin Khlebnikov Cc: Sasha Levin Cc: Christoph Lameter Cc: Joonsoo Kim Cc: Dave Hansen Cc: Andi Kleen Cc: Ingo Molnar Cc: Thomas Gleixner Cc: "H. Peter Anvin" Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Arnd Bergmann --- include/linux/module.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/include/linux/module.h b/include/linux/module.h index f520a767c86c..ac1e65afc5a1 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)