diff mbox

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

Message ID 1264758203-7591-1-git-send-email-stefan.bader@canonical.com
State Accepted
Delegated to: Stefan Bader
Headers show

Commit Message

Stefan Bader Jan. 29, 2010, 9:43 a.m. UTC
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.

-Stefan

From 0a1c275a44db55b2624652b04d4ed9430e82957b Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@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@xmission.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Tavis Ormandy <taviso@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 fs/fcntl.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Andy Whitcroft Jan. 29, 2010, 9:52 a.m. UTC | #1
On Fri, Jan 29, 2010 at 10:43:23AM +0100, Stefan Bader wrote:
> 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.

Seems that there is a known case where we can call it with IRQs disabled,
and with the _irq variant all sorts of hard to diagnose hangs would
be possible.  I'd support putting that in given its a call which can be
tickled from userspace.

-apw
Tim Gardner Jan. 29, 2010, 2:48 p.m. UTC | #2
Stefan Bader wrote:
> 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.
> 
> -Stefan
> 
> From 0a1c275a44db55b2624652b04d4ed9430e82957b Mon Sep 17 00:00:00 2001
> From: Greg Kroah-Hartman <gregkh@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@xmission.com>
> Cc: Al Viro <viro@ZenIV.linux.org.uk>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
> Cc: Tavis Ormandy <taviso@google.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Stefan Bader <stefan.bader@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) {
>  		put_pid(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,

Acked-by: Tim Gardner <tim.gardner@canonical.com>
Stefan Bader Feb. 9, 2010, 7:33 p.m. UTC | #3
Applied and pushed
diff mbox

Patch

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) {
 		put_pid(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,