Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 4 product line. The current stable release is 4.9. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 448934

Summary: Patch for bug 435280 introduces possibility of dead lock
Product: Red Hat Enterprise Linux 4 Reporter: Vitaly Mayatskikh <vmayatsk>
Component: kernelAssignee: Vitaly Mayatskikh <vmayatsk>
Status: CLOSED ERRATA QA Contact: Martin Jenner <mjenner>
Severity: high Docs Contact:
Priority: high    
Version: 4.7CC: vgoyal
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHSA-2008-0665 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-07-24 19:29:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 456631    
Attachments:
Description Flags
The patch itself none

Description Vitaly Mayatskikh 2008-05-29 15:30:40 UTC
File: linux-2.6.9-sys_times-Fix-system-unresponsiveness-during-many-c.patch

diff -up linux-2.6.9/kernel/sys.c.orig linux-2.6.9/kernel/sys.c
--- linux-2.6.9/kernel/sys.c.orig	2008-04-04 10:42:38.000000000 +0200
+++ linux-2.6.9/kernel/sys.c	2008-05-29 10:56:42.000000000 +0200
@@ -975,7 +975,8 @@ asmlinkage long sys_times(struct tms __u
 		struct task_struct *t;
 		unsigned long utime, stime, cutime, cstime;
 
-		read_lock(&tasklist_lock);
+		spin_lock_irq(&tsk->proc_lock);
+		spin_lock_irq(&tsk->sighand->siglock);
 		utime = tsk->signal->utime;
 		stime = tsk->signal->stime;
 		t = tsk;
@@ -994,11 +995,10 @@ asmlinkage long sys_times(struct tms __u
 		 * To make sure we always see that pair updated atomically,
 		 * we take the siglock around fetching them.
 		 */
-		spin_lock_irq(&tsk->sighand->siglock);
 		cutime = tsk->signal->cutime;
 		cstime = tsk->signal->cstime;
 		spin_unlock_irq(&tsk->sighand->siglock);
+		spin_unlock_irq(&tsk->proc_lock);
-		read_unlock(&tasklist_lock);
 
 		tmp.tms_utime = jiffies_to_clock_t(utime);
 		tmp.tms_stime = jiffies_to_clock_t(stime);

Peter Zijlstra noticed incorrect order of locks acquiring:

"This one can actually cause trouble, you already enabled IRQs one line
up, so _IF_ an interrupt happens while we still hold the proc_lock, and
that interrupt also wants to acquire the lock, we deadlock!"

Other notice was:

"Hmm, other code doesn't seem to require proc_lock to be irq safe - so
why was this done?"

Comment 1 Linda Wang 2008-06-03 19:02:37 UTC
This ia follow-on clean up patch for bug 435280, posted by Vitaly
and integrated/merged in on -71.EL



Comment 3 Vitaly Mayatskikh 2008-06-03 20:03:04 UTC
Created attachment 308287 [details]
The patch itself

Comment 4 Vivek Goyal 2008-06-05 17:36:09 UTC
Committed in 72.EL . RPMS are available at http://people.redhat.com/vgoyal/rhel4/

Comment 7 errata-xmlrpc 2008-07-24 19:29:59 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2008-0665.html