lkml.org 
[lkml]   [2017]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH] Arm: mm: ftrace: Only set text back to ro after kernel has been marked ro
    On Tue, Dec 5, 2017 at 5:36 AM, Russell King - ARM Linux
    <linux@armlinux.org.uk> wrote:
    > On Tue, Dec 05, 2017 at 01:30:11PM +0000, Phil Elwell wrote:
    >> This was my initial explanation:
    >>
    >> 1. Data which is marked __ro_after_init is initially writeable.
    >>
    >> 2. The ro_perms data covers kernel text, read-only data and __ro_after_init data.
    >>
    >> 3. set_kernel_text_rw marks everything in ro_perms as writeable.
    >>
    >> 4. set_kernel_text_ro marks everything in ro_perms as read-only, including the __ro_after_init data.
    >>
    >> 5. Using the function tracing code involves code modification, resulting in calls to
    >> __ftrace_modify_code and set_kernel_text_ro.
    >>
    >> 6. Therefore if function tracing is enabled before kernel_init has completed then the __ro_after_init
    >> data is made read-only prematurely.
    >
    > My question still stands, but let me rephrase. Do we need
    > set_kernel_text_*() to touch the read-only data?

    We don't _need_ to, but they're all contiguous, so the ro_perms array
    used by set_kernel_text_*() is actually only a single entry:

    static struct section_perm ro_perms[] = {
    /* Make kernel code and rodata RX (set RO). */
    {
    .name = "text/rodata RO",
    .start = (unsigned long)_stext,
    .end = (unsigned long)__init_begin,
    ...


    -Kees

    --
    Kees Cook
    Pixel Security

    \
     
     \ /
      Last update: 2017-12-05 20:36    [W:3.072 / U:0.836 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site