[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <4883FED1-D0EC-41B0-A90F-1A697756D41D@gmail.com>
Date: Mon, 3 Dec 2018 17:43:11 -0800
From: Nadav Amit <nadav.amit@...il.com>
To: Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Andy Lutomirski <luto@...nel.org>,
Will Deacon <will.deacon@....com>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
Kernel Hardening <kernel-hardening@...ts.openwall.com>,
naveen.n.rao@...ux.vnet.ibm.com, anil.s.keshavamurthy@...el.com,
David Miller <davem@...emloft.net>,
Masami Hiramatsu <mhiramat@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>, ast@...nel.org,
Daniel Borkmann <daniel@...earbox.net>, jeyu@...nel.org,
netdev@...r.kernel.org, Ard Biesheuvel <ard.biesheuvel@...aro.org>,
Jann Horn <jannh@...gle.com>, kristen@...ux.intel.com,
Dave Hansen <dave.hansen@...el.com>, deneen.t.dock@...el.com,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH 1/2] vmalloc: New flag for flush before releasing pages
> On Nov 27, 2018, at 4:07 PM, Rick Edgecombe <rick.p.edgecombe@...el.com> wrote:
>
> Since vfree will lazily flush the TLB, but not lazily free the underlying pages,
> it often leaves stale TLB entries to freed pages that could get re-used. This is
> undesirable for cases where the memory being freed has special permissions such
> as executable.
So I am trying to finish my patch-set for preventing transient W+X mappings
from taking space, by handling kprobes & ftrace that I missed (thanks again for
pointing it out).
But all of the sudden, I don’t understand why we have the problem that this
(your) patch-set deals with at all. We already change the mappings to make
the memory writable before freeing the memory, so why can’t we make it
non-executable at the same time? Actually, why do we make the module memory,
including its data executable before freeing it???
In other words: disable_ro_nx() is called by free_module() before freeing
the memory. Wouldn’t inverting the logic makes much more sense? I am
confused.
-- >8 --
From: Nadav Amit <namit@...are.com>
Subject: [PATCH] modules: disable_ro_nx() should enable nx
---
kernel/module.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/module.c b/kernel/module.c
index 7cb207249437..e12d760ea3b0 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2029,14 +2029,13 @@ void set_all_modules_text_ro(void)
static void disable_ro_nx(const struct module_layout *layout)
{
+ frob_text(layout, set_memory_nx);
+
if (rodata_enabled) {
frob_text(layout, set_memory_rw);
frob_rodata(layout, set_memory_rw);
frob_ro_after_init(layout, set_memory_rw);
}
- frob_rodata(layout, set_memory_x);
- frob_ro_after_init(layout, set_memory_x);
- frob_writable_data(layout, set_memory_x);
}
#else
--
2.17.1
Powered by blists - more mailing lists