Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752823AbbKYLO6 (ORCPT ); Wed, 25 Nov 2015 06:14:58 -0500 Received: from r00tworld.com ([212.85.137.150]:46350 "EHLO r00tworld.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751671AbbKYLO4 (ORCPT ); Wed, 25 Nov 2015 06:14:56 -0500 From: "PaX Team" To: Mathias Krause , kernel-hardening@lists.openwall.com, Clemens Ladisch Date: Wed, 25 Nov 2015 12:14:29 +0100 MIME-Version: 1.0 Subject: Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Reply-to: pageexec@freemail.hu CC: "linux-kernel@vger.kernel.org" , Kees Cook , Andy Lutomirski , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , x86-ml , Arnd Bergmann , Michael Ellerman , linux-arch@vger.kernel.org, Emese Revfy Message-ID: <56559815.30416.DC24D0B@pageexec.freemail.hu> In-reply-to: <56558826.1060202@ladisch.de> References: <1448401114-24650-1-git-send-email-keescook@chromium.org>, , <56558826.1060202@ladisch.de> X-mailer: Pegasus Mail for Windows (4.70) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.12 (r00tworld.com [212.85.137.150]); Wed, 25 Nov 2015 12:14:23 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1264 Lines: 27 On 25 Nov 2015 at 11:06, Clemens Ladisch wrote: > Mathias Krause wrote: > > [...] > > So, prior extending the usage of the __read_only annotation some > > toolchain support is needed. Maybe a gcc plugin that'll warn/error on > > code that writes to such a variable but is not __init itself. > > Or mark them as "const". This would require the initialization code to > cast it away, probably with a helper macro. no, that'd be undefined behaviour and in practice gcc would take advantage of it and produce unintended (and quite broken) code. if the constified object is modified from a different translation unit then the compiler is free to assume that it can constant propagate its initialization value into uses, completely breaking the code that (forcibly) writes to it. however as a poor man's detector for such __read_only violations it's possible to just make the object const temporarily (without casting away the write attempts!), recompile the tree and see if any writes outside __init functions pop up. -- 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/