From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751340AbdH2C04 (ORCPT ); Mon, 28 Aug 2017 22:26:56 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:54453 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbdH2C0z (ORCPT ); Mon, 28 Aug 2017 22:26:55 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Mon, 28 Aug 2017 19:24:07 -0700 From: Stefan Agner To: Kees Cook , Nick Desaulniers Cc: Jessica Yu , Matthias Kaehlcke , Rusty Russell , LKML , Masahiro Yamada , Michal Marek , Arnd Bergmann , Doug Anderson , Grant Grundler , Greg Hackmann , Michael Davidson , Alexander Potapenko , Bernhard.Rosenkranzer@linaro.org, keescook@google.com Subject: Re: module: Remove const attribute from alias for MODULE_DEVICE_TABLE In-Reply-To: References: <20170725012725.120097-1-mka@chromium.org> <9a909feb016e0c38d42d7c1fc0ce7dd0@agner.ch> Message-ID: <0f65aa38c08597209d8635cc14ac36e3@agner.ch> User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017-08-28 10:41, Kees Cook wrote: > On Mon, Aug 28, 2017 at 10:38 AM, Nick Desaulniers > wrote: >> I think Kees' proposal is a better solution; rather than require all >> usage of device table to remember to add const, have the macro add it >> for all users. Otherwise if you require caller's to add it, they may >> forget. > > And with the coccinelle script, it should be easy to invert the logic > and remove const from the callers... > I tried to reproduce my findings again but was not successful :-( I must have changed .config or something in between and draw wrong conclusions... So removing the const in the module.h alias actually did not change anything... It did not help for drivers which forget to constify... I think even the alias in module.h was actually illegal according to C standard: (C89, 6.2.7p2) "All declarations that refer to the same object or function shall have compatible type; otherwise the behavior is undefined." I guess it would still make sense to constify the structs for most of the 620 drivers which do not have it const currently. I found some driver actually change the table at runtime, e.g. drivers/net/usb/pegasus.c, so we would have to exclude them. -- Stefan