lkml.org 
[lkml]   [2017]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] MIPS: Add nonxstack=on|off kernel parameter
From
Date
On 11/30/2017 05:06 AM, Miodrag Dinic wrote:
> Hi James,
>
>>> We do have PT_GNU_STACK flags set correctly, this feature is required to
>>> workaround CPU revisions which do not have RIXI support.
>>
>> RIXI support can be discovered programatically from CP0_Config3.RXI
>> (cpu_has_rixi in asm/cpu-features.h), so I don't follow why CPUs without
>> RIXI would require a kernel parameter.
>
> The following patch introduced change in behavior with regards to
> stack & heap execute-ability :
> commit 1a770b85c1f1c1ee37afd7cef5237ffc4c970f04
> Author: Paul Burton <paul.burton@imgtec.com>
> Date: Fri Jul 8 11:06:20 2016 +0100
>
> MIPS: non-exec stack & heap when non-exec PT_GNU_STACK is present
>
> The stack and heap have both been executable by default on MIPS until
> now. This patch changes the default to be non-executable, but only for
> ELF binaries with a non-executable PT_GNU_STACK header present. This
> does apply to both the heap & the stack, despite the name PT_GNU_STACK,
> and this matches the behaviour of other architectures like ARM & x86.
>
> Current MIPS toolchains do not produce the PT_GNU_STACK header, which
> means that we can rely upon this patch not changing the behaviour of
> existing binaries. The new default will only take effect for newly
> compiled binaries once toolchains are updated to support PT_GNU_STACK,
> and since those binaries are newly compiled they can be compiled
> expecting the change in default behaviour. Again this matches the way in
> which the ARM & x86 architectures handled their implementations of
> non-executable memory.
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
> Cc: Maciej Rozycki <maciej.rozycki@imgtec.com>
> Cc: Faraz Shahbazker <faraz.shahbazker@imgtec.com>
> Cc: Raghu Gandham <raghu.gandham@imgtec.com>
> Cc: Matthew Fortune <matthew.fortune@imgtec.com>
> Cc: linux-mips@linux-mips.org
> Patchwork: https://patchwork.linux-mips.org/patch/13765/
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
>
> ....
>
> When kernel is detecting the type of mapping it should apply :
>
> fs/binfmt_elf.c:
> ...
> if (elf_read_implies_exec(loc->elf_ex, executable_stack))
> current->personality |= READ_IMPLIES_EXEC;
> ...
>
> this effectively calls mips_elf_read_implies_exec() which performs a check:
> ...
> if (!cpu_has_rixi) {
> /* The CPU doesn't support non-executable memory */
> return 1;
> }
>
> return 0;
> }
>
> This will in turn make stack & heap executable on processors without RIXI, which are practically all processors with MIPS ISA R < 6.
>

All Cavium processors since OCTEON Plus (more than ten years ago)
support RIXI.

> We would like to have an option to override this and force non-executable mappings for such systems.

This is what I don't understand. If a system doesn't support XI, then
no mapping can possibly be non-executable.

There may be some utility in disabling the use of the RIXI bits on
systems that do support them. But no command line can conjure
functional RIXI on systems that don't support it.

Also, this does nothing for multi-threaded programs where libc sets the
permissions on the thread stacks.

If you really need something, at a minimum, use the same parameter name
that x86 uses.


\
 
 \ /
  Last update: 2017-12-01 18:39    [W:0.104 / U:1.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site