Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 0b6d2921 authored by Anjana V Kumar's avatar Anjana V Kumar Committed by Osvaldo Banuelos
Browse files

cgroup: fix to break the while loop in cgroup_attach_task() correctly



Both Anjana and Eunki reported a stall in the while_each_thread loop
in cgroup_attach_task().

It's because, when we attach a single thread to a cgroup, if the cgroup
is exiting or is already in that cgroup, we won't break the loop.

If the task is already in the cgroup, the bug can lead to another thread
being attached to the cgroup unexpectedly:

  # echo 5207 > tasks
  # cat tasks
  5207
  # echo 5207 > tasks
  # cat tasks
  5207
  5215

What's worse, if the task to be attached isn't the leader of the thread
group, we might never exit the loop, hence cpu stall. Thanks for Oleg's
analysis.

This bug was introduced by commit 081aa458
("cgroup: consolidate cgroup_attach_task() and cgroup_attach_proc()")

[ lizf: - fixed the first continue, pointed out by Oleg,
        - rewrote changelog. ]

Change-Id: Ic2d5ac051880a4ff9fb358f38a452f3f3709c84e
Cc: <stable@vger.kernel.org> # 3.9+
Reported-by: default avatarEunki Kim <eunki_kim@samsung.com>
Reported-by: default avatarAnjana V Kumar <anjanavk12@gmail.com>
Signed-off-by: default avatarAnjana V Kumar <anjanavk12@gmail.com>
Signed-off-by: default avatarLi Zefan <lizefan@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Git-commit: ea84753c98a7ac6b74e530b64c444a912b3835ca
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Signed-off-by: default avatarOsvaldo Banuelos <osvaldob@codeaurora.org>
parent a479b876
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment