[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1303336844-31074-1-git-send-email-andi@firstfloor.org>
Date: Wed, 20 Apr 2011 15:00:44 -0700
From: Andi Kleen <andi@...stfloor.org>
To: jmorris@...ei.org
Cc: linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>
Subject: [PATCH] SMACK: Add missing rcu_read_lock/unlock for process capability walk.
From: Andi Kleen <ak@...ux.intel.com>
smk_access_entry does a RCU list walk for a list shared with other
threads. It relies on the caller doing rcu_read_lock().
One caller forgot to do to this, which could lead to races
on preemptible kernels.
Move the rcu_read_lock() into smk_access_entry instead.
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
security/smack/smack_access.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index 7b0d3b3..43b20f3 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -92,6 +92,7 @@ int smk_access_entry(char *subject_label, char *object_label,
int may = -ENOENT;
struct smack_rule *srp;
+ rcu_read_lock();
list_for_each_entry_rcu(srp, rule_list, list) {
if (srp->smk_subject == subject_label ||
strcmp(srp->smk_subject, subject_label) == 0) {
@@ -102,6 +103,7 @@ int smk_access_entry(char *subject_label, char *object_label,
}
}
}
+ rcu_read_unlock();
return may;
}
@@ -184,9 +186,7 @@ int smk_access_flags(char *subject_label, char *object_label, int request,
* good. A negative response from smk_access_entry()
* indicates there is no entry for this pair.
*/
- rcu_read_lock();
may = smk_access_entry(subject_label, object_label, &smack_rule_list);
- rcu_read_unlock();
if (may > 0 && (request & may) == request)
goto out_audit;
--
1.7.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists