Skip to content

Commit 2fcb409

Browse files
jmberg-intelrichardweinberger
authored andcommitted
Revert "um: allocate a guard page to helper threads"
This reverts commit ef4459a ("um: allocate a guard page to helper threads"), it's broken in multiple ways: 1) the free no longer matches the alloc; and 2) more importantly, the set_memory_ro() causes allocation of page tables for the normal memory that doesn't have any, and that later causes corruption and crashes (usually but not always in vfree()). We could fix the first bug and use vmalloc() to work around the second, but set_memory_ro() actually doesn't do anything either so I'll just revert that as well. Reported-by: Benjamin Berg <[email protected]> Fixes: ef4459a ("um: allocate a guard page to helper threads") Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent f4172b0 commit 2fcb409

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

arch/um/drivers/ubd_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ static int __init ubd_driver_init(void){
12411241
/* Letting ubd=sync be like using ubd#s= instead of ubd#= is
12421242
* enough. So use anyway the io thread. */
12431243
}
1244-
stack = alloc_stack(0);
1244+
stack = alloc_stack(0, 0);
12451245
io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *),
12461246
&thread_fd);
12471247
if(io_pid < 0){

arch/um/include/shared/kern_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern int kmalloc_ok;
1919
#define UML_ROUND_UP(addr) \
2020
((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK)
2121

22-
extern unsigned long alloc_stack(int atomic);
22+
extern unsigned long alloc_stack(int order, int atomic);
2323
extern void free_stack(unsigned long stack, int order);
2424

2525
struct pt_regs;

arch/um/kernel/process.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <os.h>
3333
#include <skas.h>
3434
#include <linux/time-internal.h>
35-
#include <asm/set_memory.h>
3635

3736
/*
3837
* This is a per-cpu array. A processor only modifies its entry and it only
@@ -63,18 +62,16 @@ void free_stack(unsigned long stack, int order)
6362
free_pages(stack, order);
6463
}
6564

66-
unsigned long alloc_stack(int atomic)
65+
unsigned long alloc_stack(int order, int atomic)
6766
{
68-
unsigned long addr;
67+
unsigned long page;
6968
gfp_t flags = GFP_KERNEL;
7069

7170
if (atomic)
7271
flags = GFP_ATOMIC;
73-
addr = __get_free_pages(flags, 1);
72+
page = __get_free_pages(flags, order);
7473

75-
set_memory_ro(addr, 1);
76-
77-
return addr + PAGE_SIZE;
74+
return page;
7875
}
7976

8077
static inline void set_current(struct task_struct *task)

arch/um/os-Linux/helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
4545
unsigned long stack, sp;
4646
int pid, fds[2], ret, n;
4747

48-
stack = alloc_stack(__cant_sleep());
48+
stack = alloc_stack(0, __cant_sleep());
4949
if (stack == 0)
5050
return -ENOMEM;
5151

@@ -116,7 +116,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
116116
unsigned long stack, sp;
117117
int pid, status, err;
118118

119-
stack = alloc_stack(__cant_sleep());
119+
stack = alloc_stack(0, __cant_sleep());
120120
if (stack == 0)
121121
return -ENOMEM;
122122

0 commit comments

Comments
 (0)