Patchwork [Natty,SRU] UBUNTU: SAUCE: fix yama_ptracer_del lockdep warning

login
register
mail settings
Submitter Ming Lei
Date June 29, 2011, 1:20 p.m.
Message ID <20110629212012.4377f687@tom-ThinkPad-T410>
Download mbox | patch
Permalink /patch/102603/
State New
Headers show

Comments

Ming Lei - June 29, 2011, 1:20 p.m.
From 7e597da6c9b6aea298ac8fdf93951a4d4b259d68 Mon Sep 17 00:00:00 2001
From: Ming Lei <ming.lei@canonical.com>
Date: Wed, 29 Jun 2011 19:06:25 +0800
Subject: [PATCH] [Natty SRU] UBUNTU: SAUCE: fix yama_ptracer_del lockdep warning

yama_ptracer_del can be called in softirq context, also
can be run in common process context, so take spin_lock_bh
in yama_ptracer_del to fix it, othewise deadlock may be
produced.

SRU Justification:

Impact:
	- lockdep warning is triggered if lockdep config options are
	  enabled
	- probably deadlock can be produced in yama_ptracer_del path

Fix:
	- After applying the patch, lockdep warning is fixefd

BugLink: http://bugs.launchpad.net/bugs/791019

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 security/yama/yama_lsm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Tim Gardner - June 29, 2011, 1:52 p.m.
On 06/29/2011 02:20 PM, Ming Lei wrote:
>  From 7e597da6c9b6aea298ac8fdf93951a4d4b259d68 Mon Sep 17 00:00:00 2001
> From: Ming Lei<ming.lei@canonical.com>
> Date: Wed, 29 Jun 2011 19:06:25 +0800
> Subject: [PATCH] [Natty SRU] UBUNTU: SAUCE: fix yama_ptracer_del lockdep warning
>
> yama_ptracer_del can be called in softirq context, also
> can be run in common process context, so take spin_lock_bh
> in yama_ptracer_del to fix it, othewise deadlock may be
> produced.
>
> SRU Justification:
>
> Impact:
> 	- lockdep warning is triggered if lockdep config options are
> 	  enabled
> 	- probably deadlock can be produced in yama_ptracer_del path
>
> Fix:
> 	- After applying the patch, lockdep warning is fixefd
>
> BugLink: http://bugs.launchpad.net/bugs/791019
>
> Signed-off-by: Ming Lei<ming.lei@canonical.com>
> ---
>   security/yama/yama_lsm.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
> index 7c3591a..927e6ad 100644
> --- a/security/yama/yama_lsm.c
> +++ b/security/yama/yama_lsm.c
> @@ -82,7 +82,7 @@ static void yama_ptracer_del(struct task_struct *tracer,
>   	struct ptrace_relation *relation;
>   	struct list_head *list, *safe;
>
> -	spin_lock(&ptracer_relations_lock);
> +	spin_lock_bh(&ptracer_relations_lock);
>   	list_for_each_safe(list, safe,&ptracer_relations) {
>   		relation = list_entry(list, struct ptrace_relation, node);
>   		if (relation->tracee == tracee ||
> @@ -91,7 +91,7 @@ static void yama_ptracer_del(struct task_struct *tracer,
>   			kfree(relation);
>   		}
>   	}
> -	spin_unlock(&ptracer_relations_lock);
> +	spin_unlock_bh(&ptracer_relations_lock);
>   }
>
>   /**

If yama_ptracer_del() can be called in soft IRQ context, then there 
appear to be other uses of ptracer_relations_lock that should also be 
spin_unlock_bh().

rtg
Ming Lei - June 29, 2011, 4:20 p.m.
Hi,

On Wed, 29 Jun 2011 14:52:30 +0100
Tim Gardner <tim.gardner@canonical.com> wrote:

> If yama_ptracer_del() can be called in soft IRQ context, then there 
> appear to be other uses of ptracer_relations_lock that should also be 
> spin_unlock_bh().

Yes, you are correct, and I will update the patch.


thanks,
--
Ming Lei

Patch

diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index 7c3591a..927e6ad 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -82,7 +82,7 @@  static void yama_ptracer_del(struct task_struct *tracer,
 	struct ptrace_relation *relation;
 	struct list_head *list, *safe;
 
-	spin_lock(&ptracer_relations_lock);
+	spin_lock_bh(&ptracer_relations_lock);
 	list_for_each_safe(list, safe, &ptracer_relations) {
 		relation = list_entry(list, struct ptrace_relation, node);
 		if (relation->tracee == tracee ||
@@ -91,7 +91,7 @@  static void yama_ptracer_del(struct task_struct *tracer,
 			kfree(relation);
 		}
 	}
-	spin_unlock(&ptracer_relations_lock);
+	spin_unlock_bh(&ptracer_relations_lock);
 }
 
 /**