aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHong-Mei Li <a21834@motorola.com>2015-06-03 14:28:48 -0700
committerSimon Shields <keepcalm444@gmail.com>2016-06-13 14:47:38 +1000
commit51ec83132ab250883b0a1393dd73cbfdb92226cb (patch)
tree71efee9c4b2d98004b3654b6acef5ea58ee112dc /include
parentaecd4580a1ffb38b53a49b482f286f6d04304e5d (diff)
downloadkernel_samsung_smdk4412-51ec83132ab250883b0a1393dd73cbfdb92226cb.tar.gz
kernel_samsung_smdk4412-51ec83132ab250883b0a1393dd73cbfdb92226cb.tar.bz2
kernel_samsung_smdk4412-51ec83132ab250883b0a1393dd73cbfdb92226cb.zip
kernel: avoid adding non-thread-group task to LMK rbtree
To maintain the task adj RB tree, we add a task to the RB tree when fork, and delete it when exit. The place is exactly the same as the linear p->tasks list, only when the task is thread_group_leader. But to handle the oom_score_adj change case, which did not check the thread_group_leader, we may del/add a non-leader task to the RB tree. Finally leave the task in the RB tree, since we would not really delete a non-leader task from the tree. The orphan task would finally be freed, and cause later use-after-free panic when accessing RB tree. Solution: Move the rbtree adj_node to signal_struct, which is shared between task and all threads. This can make sure we only add one node for a thread group. Change-Id: I1e8dfe490656408863b3726c7bc9e4ee6dc5abc1 Signed-off-by: Hong-Mei Li <a21834@motorola.com> Reviewed-on: http://gerrit.mot.com/754224 SLTApproved: Slta Waiver <sltawvr@motorola.com> SME-Granted: SME Approvals Granted Tested-by: Jira Key <jirakey@motorola.com> Reviewed-by: Zhi-Ming Yuan <a14194@motorola.com> Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com> Submit-Approved: Jira Key <jirakey@motorola.com> (cherry picked from commit b3f12a2465542888ec5c868c38022e0e5f7631ca) Signed-off-by: Abdul Salam <salamab@motorola.com> Reviewed-on: http://gerrit.mot.com/766108 Reviewed-by: Sudharsan Yettapu <sudharsan.yettapu@motorola.com> Reviewed-by: Ravikumar Vembu <raviv@motorola.com> (cherry picked from commit 558ef1fceae5d4c8509cb2a40d98c841525f7ea3) Reviewed-on: http://gerrit.mot.com/768300 Conflicts: kernel/fork.c
Diffstat (limited to 'include')
-rw-r--r--include/linux/sched.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ad2f17f36ab..6d2e88872e9 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -645,11 +645,13 @@ struct signal_struct {
struct rw_semaphore threadgroup_fork_lock;
#endif
- int oom_adj; /* OOM kill score adjustment (bit shift) */
- int oom_score_adj; /* OOM kill score adjustment */
- int oom_score_adj_min; /* OOM kill score adjustment minimum value.
+ int oom_adj; /* OOM kill score adjustment (bit shift) */
+ short oom_score_adj; /* OOM kill score adjustment */
+ short oom_score_adj_min;/* OOM kill score adjustment min value.
* Only settable by CAP_SYS_RESOURCE. */
-
+#ifdef CONFIG_ANDROID_LMK_ADJ_RBTREE
+ struct rb_node adj_node;
+#endif
struct mutex cred_guard_mutex; /* guard against foreign influences on
* credential calculations
* (notably. ptrace) */