lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 26 Aug 2019 15:41:24 +0000
From:   Nadav Amit <namit@...are.com>
To:     Steven Rostedt <rostedt@...dmis.org>,
        Peter Zijlstra <peterz@...radead.org>
CC:     Song Liu <songliubraving@...com>,
        LKML <linux-kernel@...r.kernel.org>,
        Linux-MM <linux-mm@...ck.org>,
        "kernel-team@...com" <kernel-team@...com>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Dave Hansen <dave.hansen@...el.com>,
        Andy Lutomirski <luto@...capital.net>,
        Daniel Bristot de Oliveira <bristot@...hat.com>
Subject: Re: [PATCH] x86/mm: Do not split_large_page() for
 set_kernel_text_rw()

> On Aug 26, 2019, at 4:33 AM, Steven Rostedt <rostedt@...dmis.org> wrote:
> 
> On Fri, 23 Aug 2019 11:36:37 +0200
> Peter Zijlstra <peterz@...radead.org> wrote:
> 
>> On Thu, Aug 22, 2019 at 10:23:35PM -0700, Song Liu wrote:
>>> As 4k pages check was removed from cpa [1], set_kernel_text_rw() leads to
>>> split_large_page() for all kernel text pages. This means a single kprobe
>>> will put all kernel text in 4k pages:
>>> 
>>>  root@ ~# grep ffff81000000- /sys/kernel/debug/page_tables/kernel
>>>  0xffffffff81000000-0xffffffff82400000     20M  ro    PSE      x  pmd
>>> 
>>>  root@ ~# echo ONE_KPROBE >> /sys/kernel/debug/tracing/kprobe_events
>>>  root@ ~# echo 1 > /sys/kernel/debug/tracing/events/kprobes/enable
>>> 
>>>  root@ ~# grep ffff81000000- /sys/kernel/debug/page_tables/kernel
>>>  0xffffffff81000000-0xffffffff82400000     20M  ro             x  pte
>>> 
>>> To fix this issue, introduce CPA_FLIP_TEXT_RW to bypass "Text RO" check
>>> in static_protections().
>>> 
>>> Two helper functions set_text_rw() and set_text_ro() are added to flip
>>> _PAGE_RW bit for kernel text.
>>> 
>>> [1] commit 585948f4f695 ("x86/mm/cpa: Avoid the 4k pages check completely")  
>> 
>> ARGH; so this is because ftrace flips the whole kernel range to RW and
>> back for giggles? I'm thinking _that_ is a bug, it's a clear W^X
>> violation.
> 
> Since ftrace did this way before text_poke existed and way before
> anybody cared (back in 2007), it's not really a bug.
> 
> Anyway, I believe Nadav has some patches that converts ftrace to use
> the shadow page modification trick somewhere.

For the record - here is my previous patch:
https://lkml.org/lkml/2018/12/5/211

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ