From patchwork Wed Jun 29 17:19:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 102643 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 325FEB6F59 for ; Thu, 30 Jun 2011 03:19:16 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QbyPo-0001de-6r; Wed, 29 Jun 2011 17:19:04 +0000 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QbyPm-0001dY-Ux for kernel-team@lists.ubuntu.com; Wed, 29 Jun 2011 17:19:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QbyPm-0004QD-Rm for ; Wed, 29 Jun 2011 17:19:02 +0000 Received: from [83.141.95.158] (helo=tom-ThinkPad-T410) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1QbyPm-00034w-OD for kernel-team@lists.ubuntu.com; Wed, 29 Jun 2011 17:19:02 +0000 Date: Thu, 30 Jun 2011 01:19:02 +0800 From: Ming Lei To: kernel-team@lists.ubuntu.com Subject: [PATCH] [Natty SRU] UBUNTU: SAUCE: fix yama_ptracer_del lockdep warning(v1) Message-ID: <20110630011902.08733c9e@tom-ThinkPad-T410> Organization: ubuntu X-Mailer: Claws Mail 3.7.8 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From a3bea763772d6f0f672b76f26dd6152d6d40812f Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Wed, 29 Jun 2011 19:06:25 +0800 Subject: [PATCH] [Natty SRU] UBUNTU: SAUCE: fix yama_ptracer_del lockdep warning(v1) yama_ptracer_del can be called in softirq context, so ptracer_relations_lock may be held in softirq context. This patch replaces spin_[un]lock with spin_[un]lock_bh for &ptracer_relations_lock to fix reported lockdep warning and avoid possible dealock. 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 Acked-by: Tim Gardner for Natty and Oneiric Acked-by: Stefan Bader --- security/yama/yama_lsm.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index 7c3591a..b200e33 100644 --- a/security/yama/yama_lsm.c +++ b/security/yama/yama_lsm.c @@ -46,7 +46,7 @@ static int yama_ptracer_add(struct task_struct *tracer, struct ptrace_relation *entry, *relation = NULL; added = kmalloc(sizeof(*added), GFP_KERNEL); - spin_lock(&ptracer_relations_lock); + spin_lock_bh(&ptracer_relations_lock); list_for_each_entry(entry, &ptracer_relations, node) if (entry->tracee == tracee) { relation = entry; @@ -64,7 +64,7 @@ static int yama_ptracer_add(struct task_struct *tracer, relation->tracer = tracer; unlock_out: - spin_unlock(&ptracer_relations_lock); + spin_unlock_bh(&ptracer_relations_lock); if (added && added != relation) kfree(added); @@ -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); } /** @@ -205,7 +205,7 @@ static int ptracer_exception_found(struct task_struct *tracer, struct ptrace_relation *relation; struct task_struct *parent = NULL; - spin_lock(&ptracer_relations_lock); + spin_lock_bh(&ptracer_relations_lock); rcu_read_lock(); read_lock(&tasklist_lock); @@ -221,7 +221,7 @@ static int ptracer_exception_found(struct task_struct *tracer, if (task_is_descendant(parent, tracer)) rc = 1; - spin_unlock(&ptracer_relations_lock); + spin_unlock_bh(&ptracer_relations_lock); return rc; }