stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fork, memcg: fix cached_stacks case
@ 2019-01-02 18:01 Shakeel Butt
  2019-01-02 20:23 ` Michal Hocko
  2019-01-04 20:14 ` Rik van Riel
  0 siblings, 2 replies; 3+ messages in thread
From: Shakeel Butt @ 2019-01-02 18:01 UTC (permalink / raw)
  To: Rik van Riel, Roman Gushchin, Michal Hocko, Andrew Morton
  Cc: linux-mm, cgroups, linux-kernel, Shakeel Butt, Johannes Weiner,
	Tejun Heo, stable

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")
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Roman Gushchin <guro@fb.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: <stable@vger.kernel.org>
---
 kernel/fork.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index e4a51124661a..593cd1577dff 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -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;
 	}
 
-- 
2.20.1.415.g653613c723-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fork, memcg: fix cached_stacks case
  2019-01-02 18:01 [PATCH] fork, memcg: fix cached_stacks case Shakeel Butt
@ 2019-01-02 20:23 ` Michal Hocko
  2019-01-04 20:14 ` Rik van Riel
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2019-01-02 20:23 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Rik van Riel, Roman Gushchin, Andrew Morton, linux-mm, cgroups,
	linux-kernel, Johannes Weiner, Tejun Heo, stable

On Wed 02-01-19 10:01:45, Shakeel Butt wrote:
> 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")
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
> Cc: Rik van Riel <riel@surriel.com>
> Cc: Roman Gushchin <guro@fb.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: <stable@vger.kernel.org>

Ups, I have overlook that. Thanks for catching that.
Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  kernel/fork.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index e4a51124661a..593cd1577dff 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -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;
>  	}
>  
> -- 
> 2.20.1.415.g653613c723-goog
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fork, memcg: fix cached_stacks case
  2019-01-02 18:01 [PATCH] fork, memcg: fix cached_stacks case Shakeel Butt
  2019-01-02 20:23 ` Michal Hocko
@ 2019-01-04 20:14 ` Rik van Riel
  1 sibling, 0 replies; 3+ messages in thread
From: Rik van Riel @ 2019-01-04 20:14 UTC (permalink / raw)
  To: Shakeel Butt, Roman Gushchin, Michal Hocko, Andrew Morton
  Cc: linux-mm, cgroups, linux-kernel, Johannes Weiner, Tejun Heo, stable

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

On Wed, 2019-01-02 at 10:01 -0800, Shakeel Butt wrote:
> 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")
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
> Cc: Rik van Riel <riel@surriel.com>
> Cc: Roman Gushchin <guro@fb.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: <stable@vger.kernel.org>

Good catch. Thank you.

Acked-by: Rik van Riel <riel@surriel.com>

-- 
All Rights Reversed.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-04 20:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-02 18:01 [PATCH] fork, memcg: fix cached_stacks case Shakeel Butt
2019-01-02 20:23 ` Michal Hocko
2019-01-04 20:14 ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).