Skip to contentSkip to conversation

fork, memcg: fix cached_stacks case

PATCH Applied Shakeel Butt 3 participants 3 messages Jan 2, 2019 – Jan 4, 2019

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fork, memcg: fix cached_stacks case

Commit 5eed6f1dff87 ("fork,memcg: fix crash in free_thread_stack on memcg charge fail") fixes a crash caused due to failed memcg charge of the kernel stack. However the fix misses the cached_stacks case which this patch fixes. So, the same crash can happen if the memcg charge of a cached stack is failed.

Fixes 5eed6f1dff87 ("fork,memcg: fix crash in free_thread_stack on memcg charge fail")
Cc Rik van Riel <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Tejun Heo <[email protected]>
---
 kernel/fork.c | 1 +
 1 file changed, 1 insertion(+)
kernel/fork.c +1 -0
index e4a51124661a..593cd1577dff 100644
@@ -216,6 +216,7 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
 		memset(s->addr, 0, THREAD_SIZE);
 
 		tsk->stack_vm_area = s;
+		tsk->stack = s->addr;
 		return s->addr;
 	}
 
Signature · 1 line
2.20.1.415.g653613c723-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Shakeel Butt

Commit 5eed6f1dff87 ("fork,memcg: fix crash in free_thread_stack on memcg charge fail") fixes a crash caused due to failed memcg charge of the kernel stack. However the fix misses the cached_stacks case which this patch fixes. So, the same crash can happen if the memcg charge of a cached stack is failed.

Quoted 8 lines
Fixes 5eed6f1dff87 ("fork,memcg: fix crash in free_thread_stack on memcg charge fail")
Cc Rik van Riel <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Tejun Heo <[email protected]>

Ups, I have overlook that. Thanks for catching that.

Quoted 19 lines
---
 kernel/fork.c | 1 +
 1 file changed, 1 insertion(+)
kernel/fork.c +1 -0
index e4a51124661a..593cd1577dff 100644
@@ -216,6 +216,7 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
 		memset(s->addr, 0, THREAD_SIZE);
 
 		tsk->stack_vm_area = s;
+		tsk->stack = s->addr;
 		return s->addr;
 	}
 
Signature · 1 line
2.20.1.415.g653613c723-goog
Signature · 2 lines
Michal Hocko
SUSE Labs
Acked-by on v1 1/1
#2 lore raw
In reply to Shakeel Butt
Quoted 9 lines · Shakeel Butt

Commit 5eed6f1dff87 ("fork,memcg: fix crash in free_thread_stack on memcg charge fail") fixes a crash caused due to failed memcg charge of
the kernel stack. However the fix misses the cached_stacks case which this patch fixes. So, the same crash can happen if the memcg charge of
a cached stack is failed.

Fixes 5eed6f1dff87 ("fork,memcg: fix crash in free_thread_stack on
Quoted 8 lines

memcg charge fail")

Cc Rik van Riel <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Tejun Heo <[email protected]>

Good catch. Thank you.

Signature · 1 line
All Rights Reversed.