Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 1114

kernel-2.6.18-238.el5.src.rpm

From: Larry Woodman <lwoodman@redhat.com>
Date: Fri, 7 Nov 2008 08:55:14 -0500
Subject: [fs] need locking when reading /proc/<pid>/oom_score
Message-id: 1226066114.32502.12.camel@localhost.localdomain
O-Subject: [RHEL5-U4 patch] system can hang or panic can occur when /proc/<pid>/oom_score is read
Bugzilla: 470459
RH-Acked-by: Rik van Riel <riel@redhat.com>
RH-Acked-by: Pete Zaitcev <zaitcev@redhat.com>
RH-Acked-by: John Feeney <jfeeney@redhat.com>

We need to take a readlock on the tasklist_lock in proc_oom_score()
before calling badness().  Without this "upstream patch" the system can
panic or hang in badness() walking the child list.

Fixes BZ470459.

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 60c6761..e7a1f31 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -577,7 +577,9 @@ static int proc_oom_score(struct task_struct *task, char *buffer)
 	struct timespec uptime;
 
 	do_posix_clock_monotonic_gettime(&uptime);
+	read_lock(&tasklist_lock);
 	points = badness(task, uptime.tv_sec);
+	read_unlock(&tasklist_lock);
 	return sprintf(buffer, "%lu\n", points);
 }