Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751352AbbKIGJc (ORCPT ); Mon, 9 Nov 2015 01:09:32 -0500 Received: from smtprelay0039.hostedemail.com ([216.40.44.39]:47508 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750738AbbKIGJa (ORCPT ); Mon, 9 Nov 2015 01:09:30 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1605:1711:1730:1747:1777:1792:2393:2553:2559:2562:2689:2828:3138:3139:3140:3141:3142:3622:3653:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:5007:6119:6261:7903:8531:8879:9010:9040:10004:10026:10394:10400:10848:10946:11026:11232:11658:11914:12043:12220:12295:12296:12438:12517:12519:12555:12663:12740:13161:13229:14096:14097:14659:21080:30030:30054:30064:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: mice37_35947b8b95504 X-Filterd-Recvd-Size: 3909 Message-ID: <1447049367.2701.39.camel@perches.com> Subject: Re: [PATCH] video: constify geode ops structures From: Joe Perches To: Dan Carpenter , Julia Lawall Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , kernel-hardening@lists.openwall.com Date: Sun, 08 Nov 2015 22:09:27 -0800 In-Reply-To: <20151109054253.GQ18797@mwanda> References: <1447018493-20631-1-git-send-email-Julia.Lawall@lip6.fr> <20151108221624.GP18797@mwanda> <20151109054253.GQ18797@mwanda> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.16.5-1ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3078 Lines: 69 On Mon, 2015-11-09 at 08:42 +0300, Dan Carpenter wrote: > On Sun, Nov 08, 2015 at 10:24:49PM +0000, Julia Lawall wrote: > > On Mon, 9 Nov 2015, Dan Carpenter wrote: > > > > > Cool. So, in grsec they use a GCC plugin to make these const > > > automatically since they only contain function pointers. There about > > > 100 struct types marked as __no_const. Kees would like to adopt the > > > grsec pluggin approach I expect. Do you have an idea how many structs > > > only contain function pointers or how many consts we would have to add > > > to get the same effect without the plugin? > > > > My list has 373 type names. In the list there are counts for good > > (already const) and bad (not const). The sum of the bad values is 2467. > > The list is below. > > > > julia > > Fantastic! Thanks. We could autogenerate the list of type names and > make checkpatch.pl complain if we declared those types as non const. > > I ran this command to find which functions grsec marks as __no_const. > > egrep '(^ struct |^@@|__no_const;)' grsecurity-3.1-4.2.5-201511021814.patch | grep __no_const -B1 | grep -v __no_const | grep -v '^--' | cut -d @ -f 5- | cut -b 9- | cut -d ' ' -f 1 > > There are 60 structs declared as __no_const. For some structs they > declare a no_const version and use it as needed. Like this: > typedef struct net_device_ops __no_const net_device_ops_no_const; > > grep __no_const grsecurity-3.1-4.2.5-201511021814.patch | grep typedef | cut -d ' ' -f 3 > > There are 32 of those. > > Then I compared to see if their structs were on your list. For some > reason there quite a few one their list which are not on yours. Out > of the first 10 about half weren't on your list. cpu_cache_fns, > outer_cache_fns, psci_operations, smp_operations, omap_hwmod_soc_ops, > smp_ops_t. These are mostly different arches? > > Also bit_table has in int has well as a function pointers but it is on > their list. I'm not sure why. Maybe they are marking structs const > that I don't know about. > > The other trick that they do is they define structs as __do_const if > they want them to be const by default, which is pretty neat. This feels > like it should be a standard GCC feature. In the meantime we could > mark things as __do_const and print a sparse warning if it was declared > as not const. > > I have attached the list of __no_const structs. This would probably be better as a coccinelle script, but making checkpatch use an external list instead of the hard coded list of normally const structs (checkpatch's $const_structs variable around line 5600) is trivial. Right now, checkpatch generates a camelcase file. (.checkpatch.git.) Maybe something similar could be done or another script could be run occasionally to create this "normally_const_struct_list" file. -- 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/