linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] android, lmk: Protect task->comm with task_lock.
@ 2015-08-26 12:17 Tetsuo Handa
  2015-08-26 12:19 ` [PATCH 2/2] android, lmk: Reverse the order of setting TIF_MEMDIE and sending SIGKILL Tetsuo Handa
  2015-09-01 22:28 ` [PATCH 1/2] android, lmk: Protect task->comm with task_lock David Rientjes
  0 siblings, 2 replies; 10+ messages in thread
From: Tetsuo Handa @ 2015-08-26 12:17 UTC (permalink / raw)
  To: gregkh, arve, riandrews; +Cc: devel, linux-mm, mhocko, rientjes, hannes

Hello.

Next patch is mm-related but this patch is not.
Via which tree should these patches go?
----------------------------------------
>From 48c1b457eb32d7a029e9a078ee0a67974ada9261 Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Wed, 26 Aug 2015 20:49:17 +0900
Subject: [PATCH 1/2] android, lmk: Protect task->comm with task_lock.

Passing task->comm to printk() wants task_lock() protection in order
to avoid potentially emitting garbage bytes.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 drivers/staging/android/lowmemorykiller.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 872bd60..d5d25e4 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -134,26 +134,25 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 			return 0;
 		}
 		oom_score_adj = p->signal->oom_score_adj;
-		if (oom_score_adj < min_score_adj) {
-			task_unlock(p);
-			continue;
-		}
+		if (oom_score_adj < min_score_adj)
+			goto next;
 		tasksize = get_mm_rss(p->mm);
-		task_unlock(p);
 		if (tasksize <= 0)
-			continue;
+			goto next;
 		if (selected) {
 			if (oom_score_adj < selected_oom_score_adj)
-				continue;
+				goto next;
 			if (oom_score_adj == selected_oom_score_adj &&
 			    tasksize <= selected_tasksize)
-				continue;
+				goto next;
 		}
 		selected = p;
 		selected_tasksize = tasksize;
 		selected_oom_score_adj = oom_score_adj;
 		lowmem_print(2, "select %d (%s), adj %hd, size %d, to kill\n",
 			     p->pid, p->comm, oom_score_adj, tasksize);
+next:
+		task_unlock(p);
 	}
 	if (selected) {
 		task_lock(selected);
@@ -168,10 +167,10 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 		 * task should have access to the memory reserves.
 		 */
 		mark_oom_victim(selected);
-		task_unlock(selected);
 		lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n",
 			     selected->pid, selected->comm,
 			     selected_oom_score_adj, selected_tasksize);
+		task_unlock(selected);
 		lowmem_deathpending_timeout = jiffies + HZ;
 		send_sig(SIGKILL, selected, 0);
 		rem += selected_tasksize;
-- 
1.8.3.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2015-09-04 20:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-26 12:17 [PATCH 1/2] android, lmk: Protect task->comm with task_lock Tetsuo Handa
2015-08-26 12:19 ` [PATCH 2/2] android, lmk: Reverse the order of setting TIF_MEMDIE and sending SIGKILL Tetsuo Handa
2015-08-26 15:34   ` Tetsuo Handa
2015-08-27  8:44     ` Michal Hocko
2015-09-03  1:06   ` Greg KH
2015-09-04 14:05     ` Michal Hocko
2015-09-04 17:15       ` Greg KH
2015-09-04 18:06         ` Tetsuo Handa
2015-09-04 20:29           ` Greg KH
2015-09-01 22:28 ` [PATCH 1/2] android, lmk: Protect task->comm with task_lock David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox