From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752536AbcF1XzF (ORCPT ); Tue, 28 Jun 2016 19:55:05 -0400 Received: from smtprelay0040.hostedemail.com ([216.40.44.40]:53407 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752423AbcF1XzD (ORCPT ); Tue, 28 Jun 2016 19:55:03 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:6119:6120:6742:7901:8603:10004:10400:10848:10967:11026:11232:11658:11914:12043:12438:12517:12519:12663:12740:13069:13161:13229:13311:13357:13439:13894:14181:14659:14721:21080:21325,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:error,Custom_rules:0:0:0,LFtime:2000,LUA_SUMMARY:none X-HE-Tag: use82_799eb1db3726 X-Filterd-Recvd-Size: 2500 Message-ID: <1467158049.24287.90.camel@perches.com> Subject: Re: [kernel-hardening] Re: [PATCH v1 0/2] Introduce the initify gcc plugin From: Joe Perches To: Valdis.Kletnieks@vt.edu, kernel-hardening@lists.openwall.com Cc: Emese Revfy , Matt Davis , pageexec@freemail.hu, spender@grsecurity.net, mmarek@suse.com, keescook@chromium.org, linux-kernel@vger.kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, minipli@ld-linux.so, linux@armlinux.org.uk, catalin.marinas@arm.com, linux@rasmusvillemoes.dk, david.brown@linaro.org, benh@kernel.crashing.org, tglx@linutronix.de, akpm@linux-foundation.org, jlayton@poochiereds.net, arnd@arndb.de Date: Tue, 28 Jun 2016 16:54:09 -0700 In-Reply-To: <47053.1467151621@turing-police.cc.vt.edu> References: <20160628133407.10c2ea1ecd194e8085e84c5a@gmail.com> <1467150555.24287.77.camel@perches.com> <47053.1467151621@turing-police.cc.vt.edu> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2016-06-28 at 18:07 -0400, Valdis.Kletnieks@vt.edu wrote: > On Tue, 28 Jun 2016 14:49:15 -0700, Joe Perches said: > > > > > Another potentially useful plugin, especially for embedded systems, > > would be to compress any string literal marked with > > > >  __attribute__((format(printf, string-index,))) > > > > and decompress the compressed format on the stack in lib/vsprintf.c > > vsnprintf just before use. > Are there enough such strings in the kernel to make it worth the effort? > I'm assuming that the string literals in printk("some string here") are > automatically so marked? Yes, that's the concept. > Is there a minimum length under which the compression overhead actually > makes it larger? No, compression would have to be possible, otherwise it'd be stored directly.  Compression would use a special "compressed string" header with a 2 byte overhead and then stored with no trailing \0. Something like struct compressed_format_header { u8 flag; /* Must be ASCII STX or "\b" */ u8 length; } Depends on the config of course, but it could reduce total image size ~50k on an x86-32 defconfig