lkml.org 
[lkml]   [2019]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86/mm: Do not split_large_page() for set_kernel_text_rw()
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.

\
 
 \ /
  Last update: 2019-08-23 11:37    [W:0.974 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site