|
|
Subscribe / Log in / New account

Re: [PATCH 0/2] introduce post-init read-only memory

From:  "PaX Team" <pageexec-AT-freemail.hu>
To:  Mathias Krause <minipli-AT-googlemail.com>, kernel-hardening-AT-lists.openwall.com, Clemens Ladisch <clemens-AT-ladisch.de>
Subject:  Re: [PATCH 0/2] introduce post-init read-only memory
Date:  Wed, 25 Nov 2015 12:14:29 +0100
Message-ID:  <56559815.30416.DC24D0B@pageexec.freemail.hu>
Cc:  "linux-kernel-AT-vger.kernel.org" <linux-kernel-AT-vger.kernel.org>, Kees Cook <keescook-AT-chromium.org>, Andy Lutomirski <luto-AT-amacapital.net>, Ingo Molnar <mingo-AT-redhat.com>, Thomas Gleixner <tglx-AT-linutronix.de>, "H. Peter Anvin" <hpa-AT-zytor.com>, x86-ml <x86-AT-kernel.org>, Arnd Bergmann <arnd-AT-arndb.de>, Michael Ellerman <mpe-AT-ellerman.id.au>, linux-arch-AT-vger.kernel.org, Emese Revfy <re.emese-AT-gmail.com>
Archive‑link:  Article

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 post comments


Copyright © 2015, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds