[Karmic] SRU: fnctl: f_modown should call write_lock_irqsave/restore

Stefan Bader stefan.bader at canonical.com
Fri Jan 29 09:43:23 UTC 2010

SRU Justification:

Impact: While we have no real bug reported (at least not one we can simply
connect to it) I really would like to have this backported to Karmic.

Fix: This has gone into 2.6.32.y (and 2.6.27.y) and moving from a *_irq to
a *_irqsave variant can only make things better. Plus we might get patches
that expose the problem, too. And then forget to pull this as well.

Thoughts? I would create a bug report for it, should we decide it should
go in.


>From 0a1c275a44db55b2624652b04d4ed9430e82957b Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh at suse.de>
Date: Tue, 26 Jan 2010 15:04:02 -0800
Subject: [PATCH] fnctl: f_modown should call write_lock_irqsave/restore

commit b04da8bfdfbbd79544cab2fadfdc12e87eb01600 upstream.

Commit 703625118069f9f8960d356676662d3db5a9d116 exposed that f_modown()
should call write_lock_irqsave instead of just write_lock_irq so that
because a caller could have a spinlock held and it would not be good to
renable interrupts.

Cc: Eric W. Biederman <ebiederm at xmission.com>
Cc: Al Viro <viro at ZenIV.linux.org.uk>
Cc: Alan Cox <alan at lxorguk.ukuu.org.uk>
Cc: Tavis Ormandy <taviso at google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Stefan Bader <stefan.bader at canonical.com>
 fs/fcntl.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 97e01dc..5ef953e 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -199,7 +199,9 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
 static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
                      int force)
-	write_lock_irq(&filp->f_owner.lock);
+	unsigned long flags;
+	write_lock_irqsave(&filp->f_owner.lock, flags);
 	if (force || !filp->f_owner.pid) {
 		filp->f_owner.pid = get_pid(pid);
@@ -211,7 +213,7 @@ static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
 			filp->f_owner.euid = cred->euid;
-	write_unlock_irq(&filp->f_owner.lock);
+	write_unlock_irqrestore(&filp->f_owner.lock, flags);
 int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,

More information about the kernel-team mailing list