Skip to content

Commit 1e11ad8

Browse files
rientjestorvalds
authored andcommitted
mm, oom: fix badness score underflow
If the privileges given to root threads (3% of allowable memory) or a negative value of /proc/pid/oom_score_adj happen to exceed the amount of rss of a thread, its badness score overflows as a result of commit a7f638f ("mm, oom: normalize oom scores to oom_score_adj scale only for userspace"). Fix this by making the type signed and return 1, meaning the thread is still eligible for kill, if the value is negative. Reported-by: Dave Jones <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Signed-off-by: David Rientjes <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7249450 commit 1e11ad8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/oom_kill.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static bool oom_unkillable_task(struct task_struct *p,
183183
unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
184184
const nodemask_t *nodemask, unsigned long totalpages)
185185
{
186-
unsigned long points;
186+
long points;
187187

188188
if (oom_unkillable_task(p, memcg, nodemask))
189189
return 0;
@@ -223,7 +223,7 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg,
223223
* Never return 0 for an eligible task regardless of the root bonus and
224224
* oom_score_adj (oom_score_adj can't be OOM_SCORE_ADJ_MIN here).
225225
*/
226-
return points ? points : 1;
226+
return points > 0 ? points : 1;
227227
}
228228

229229
/*

0 commit comments

Comments
 (0)