Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1277626

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

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory
Date Wed, 25 Nov 2015 18:30:03 +0100
Message-ID <qyM3h-RQ-9@gated-at.bofh.it> (permalink)
References <qyttF-59Z-27@gated-at.bofh.it> <qyEp4-4c9-15@gated-at.bofh.it>
X-Original-To Mathias Krause <minipli@googlemail.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=trJKhp4MgnAaiX0jllV682Hoo4ix9hd8nPQq9PmB55c=; b=psVQ3CY29Uxlr8nevM8tFC9XEOUxk6OXqJ/13OvPDBp3RXBSlIhbEqw7SKwEA0kSTQ zrfuAnQJ87/TJK07VHkI2B5qWSLceyfEN3/3a2ZH0Htg3T5x4hoit2UJ85v5934a/Bgp TUqZqM+rnEAKzbdd741MC3r1xLRI2DatCJ4TBQK3DJgdTt7CM7QYN9Rwm9z7tohTWNWh GNWLDT50qoOcMvXB5YlfaUGhvwgYbkmBh1w/tDjgzeNkGdQltJxl3EwsgygAnSvBnL5i BgGKEVE3OKb7vCR0MMUmRLm2BTN+/sqc6tQUF7lEsmhERAfq1hlhyWmbz9T70Ms41kNU zKww==
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=trJKhp4MgnAaiX0jllV682Hoo4ix9hd8nPQq9PmB55c=; b=Xg4uMTfxViMjnAxIeWJFyNoICkUvdNdERry4xND9xyI8L1TzWQ+aVUt62rcu35tr5o hQg47FBtnZTzrBzJmhq51ai9Mg7t9ttJg6OFo8I9S5bHf5Zwi557PZYfw09pSzxwG3D8 lXlnl5uvc12f5IuN4S/lEeFkvT/3X4SQUOKSs=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=trJKhp4MgnAaiX0jllV682Hoo4ix9hd8nPQq9PmB55c=; b=hA00fB5pBMxZ1msQKfk8MNxqnF9FGFpbpMVwhui6XDLINAEO9+xLdFOU7htH0VzFAe +U5myWcC38t8X/zXzwuI/WIiFPcORB/h2Q5vEPZ6ymvyzbhxzELVPsMgy9f6YAspIalV fJmgNnxHgw3SAiuZltz/8s4TgOUHE5+VIXjJGoiUW8msK9sKf0fBDYdwvLc2ubCS919D roxMVs2h5zTbJvwalVerhNLqeBypvXJfoOaxPdLHwTS//h1z7GNUZJT9E6lgCLyuDpJd tWVU50YtRF3h0nhIXDd4FNN9iy+tAsC/qTn93J4Ev+WWaE/7ueJA/z7fNVXZ3zKAHPZT 1ZxQ==
X-Gm-Message-State ALoCoQm/JDEJTGgKZ7aHZoBhwcEgw2zhXQ9QPz+y2FJz3Cn91Rmb/zvBK6o/ZrvqEs429eebR15/
MIME-Version 1.0
X-Received by 10.50.65.101 with SMTP id w5mr5307673igs.3.1448472382759; Wed, 25 Nov 2015 09:26:22 -0800 (PST)
X-Google-Sender-Auth XUuASypgJiNetpIAQu5axVHKFhw
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 60
Organization linux.* mail to news gateway
X-Original-Cc "kernel-hardening@lists.openwall.com" <kernel-hardening@lists.openwall.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Andy Lutomirski <luto@amacapital.net>, Ingo Molnar <mingo@redhat.com>, Thomas Gleixner <tglx@linutronix.de>, "H. Peter Anvin" <hpa@zytor.com>, x86-ml <x86@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Michael Ellerman <mpe@ellerman.id.au>, linux-arch <linux-arch@vger.kernel.org>, PaX Team <pageexec@freemail.hu>, Emese Revfy <re.emese@gmail.com>
X-Original-Date Wed, 25 Nov 2015 09:26:22 -0800
X-Original-Message-ID <CAGXu5jLXukRLg=0i00fYjZpaVj1hzcyf81aKa6mN4LNPnsfWNw@mail.gmail.com>
X-Original-References <1448401114-24650-1-git-send-email-keescook@chromium.org> <CA+rthh-euk2hGGWjsDqXogWSmzmJNV1aiUVfnTfrzyQhndgbOQ@mail.gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1277626

Show key headers only | View raw


On Wed, Nov 25, 2015 at 1:13 AM, Mathias Krause <minipli@googlemail.com> wrote:
> On 24 November 2015 at 22:38, Kees Cook <keescook@chromium.org> wrote:
>> Many things are written to only during __init, and never changed
>> again. These cannot be made "const" since the compiler will do the wrong
>> thing (we do actually need to write to them). Instead, move these items
>> into a memory region that will be made read-only during mark_rodata_ro()
>> which happens after all kernel __init code has finished.
>>
>> This introduces __read_only as a way to mark such memory, and uses it on
>> the x86 vDSO to kill an extant kernel exploitation method.
>
> ...just some random notes on the experience with kernels implementing
> such a feature for quite a lot of locations, not just the vDSO.
>
> While having that annotation makes perfect sense, not only from a
> security perspective but also from a micro-optimization point of view
> (much like the already existing __read_mostly annotation), it has its
> drawbacks. Violating the "r/o after init" rule by writing to such
> annotated variables from non-init code goes unnoticed as far as it
> concerns the toolchain. Neither the compiler nor the linker will flag
> that incorrect use. It'll just trap at runtime and that's bad.

Well, or, it's good: that's the point of it. Either from the
perspective of robustness or from that of security.

> I myself had some educating experience seeing my machine triple fault
> when resuming from a S3 sleep. The root cause was a variable that was
> annotated __read_only but that was (unnecessarily) modified during CPU
> bring-up phase. Debugging that kind of problems is sort of a PITA, you
> could imagine.

As PaX Team mentions, it should be easy to catch these traps and
report them. That could certainly be a nice addition.

> 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. The
> initify and checker plugins from the PaX patch might be worth to look
> at for that purpose, as they're doing similar things already. Adding
> such a check to sparse might be worth it, too.
> A modpost check probably won't work as it's unable to tell if it's a
> legitimate access (r/o) or a violation (/w access). So the gcc plugin
> is the way to go, IMHO.

There are many more pieces to add to the annotation use, but I don't
want to risk getting us into a Catch-22. Emese's work on the plugin
side will see this usage and utility grow, and I think getting these
basic building blocks in place is the right place to start.

-Kees


-- 
Kees Cook
Chrome OS & Brillo Security
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] introduce post-init read-only memory Kees Cook <keescook@chromium.org> - 2015-11-24 22:40 +0100
  [PATCH 1/2] x86: introduce post-init read-only memory Kees Cook <keescook@chromium.org> - 2015-11-24 22:40 +0100
    Re: [PATCH 1/2] x86: introduce post-init read-only memory Andy Lutomirski <luto@amacapital.net> - 2015-11-25 01:40 +0100
      Re: [PATCH 1/2] x86: introduce post-init read-only memory Kees Cook <keescook@chromium.org> - 2015-11-25 01:50 +0100
        Re: [kernel-hardening] Re: [PATCH 1/2] x86: introduce post-init  read-only memory Michael Ellerman <mpe@ellerman.id.au> - 2015-11-25 02:00 +0100
          Re: [kernel-hardening] Re: [PATCH 1/2] x86: introduce post-init  read-only memory Kees Cook <keescook@chromium.org> - 2015-11-25 16:10 +0100
            Re: [kernel-hardening] Re: [PATCH 1/2] x86: introduce post-init  read-only memory Michael Ellerman <mpe@ellerman.id.au> - 2015-11-26 00:10 +0100
              Re: [kernel-hardening] Re: [PATCH 1/2] x86: introduce post-init  read-only memory Kees Cook <keescook@chromium.org> - 2015-11-26 00:40 +0100
  [PATCH 2/2] x86, vdso: mark vDSO read-only after init Kees Cook <keescook@chromium.org> - 2015-11-24 22:50 +0100
  Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Mathias Krause <minipli@googlemail.com> - 2015-11-25 10:20 +0100
    Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Clemens Ladisch <clemens@ladisch.de> - 2015-11-25 11:10 +0100
      Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory "PaX Team" <pageexec@freemail.hu> - 2015-11-25 12:20 +0100
    Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory "PaX Team" <pageexec@freemail.hu> - 2015-11-25 12:10 +0100
      Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-26 10:00 +0100
        Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory "PaX Team" <pageexec@freemail.hu> - 2015-11-26 11:00 +0100
          Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-26 11:50 +0100
            Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory "PaX Team" <pageexec@freemail.hu> - 2015-11-26 13:20 +0100
              Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-27 09:10 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory "PaX Team" <pageexec@freemail.hu> - 2015-11-27 16:40 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Andy Lutomirski <luto@amacapital.net> - 2015-11-27 17:40 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-29 09:10 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory "PaX Team" <pageexec@freemail.hu> - 2015-11-29 12:20 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-29 16:40 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Mathias Krause <minipli@googlemail.com> - 2015-11-29 19:10 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-30 09:10 +0100
        Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Andy Lutomirski <luto@amacapital.net> - 2015-11-26 17:20 +0100
          Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-27 09:10 +0100
            Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-27 19:10 +0100
            Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-27 19:10 +0100
              Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Kees Cook <keescook@chromium.org> - 2015-11-27 21:10 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Andy Lutomirski <luto@amacapital.net> - 2015-11-27 21:10 +0100
                Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory Ingo Molnar <mingo@kernel.org> - 2015-11-29 09:10 +0100
    Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Kees Cook <keescook@chromium.org> - 2015-11-25 18:30 +0100
    Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory "H. Peter Anvin" <hpa@zytor.com> - 2015-11-25 18:40 +0100
      Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only memory Kees Cook <keescook@chromium.org> - 2015-11-25 20:00 +0100
        Re: [kernel-hardening] [PATCH 0/2] introduce post-init read-only  memory "H. Peter Anvin" <hpa@zytor.com> - 2015-11-25 20:10 +0100

csiph-web