Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 3 Dec 2018 17:43:11 -0800
From: Nadav Amit <>
To: Rick Edgecombe <>
Cc: Andrew Morton <>,
 Andy Lutomirski <>,
 Will Deacon <>,
 linux-mm <>,
 LKML <>,
 Kernel Hardening <>,,,
 David Miller <>,
 Masami Hiramatsu <>,
 Steven Rostedt <>,
 Ingo Molnar <>,,
 Daniel Borkmann <>,,,
 Ard Biesheuvel <>,
 Jann Horn <>,,
 Dave Hansen <>,,
 Peter Zijlstra <>
Subject: Re: [PATCH 1/2] vmalloc: New flag for flush before releasing pages

> On Nov 27, 2018, at 4:07 PM, Rick Edgecombe <> 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

-- >8 --

From: Nadav Amit <>
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);

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.