From: Paul E. McKenney Date: Tue, 23 Feb 2010 01:04:56 +0000 (-0800) Subject: security: Apply lockdep-based checking to rcu_dereference() uses X-Git-Tag: v2.6.34-rc2~51^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7b0a61b7929632d36cf052d9e2820ef0a9c1bfe;p=platform%2Fkernel%2Flinux-3.10.git security: Apply lockdep-based checking to rcu_dereference() uses Apply lockdep-ified RCU primitives to key_gc_keyring() and keyring_destroy(). Cc: David Howells Signed-off-by: Paul E. McKenney Cc: laijs@cn.fujitsu.com Cc: dipankar@in.ibm.com Cc: mathieu.desnoyers@polymtl.ca Cc: josh@joshtriplett.org Cc: dvhltc@us.ibm.com Cc: niv@us.ibm.com Cc: peterz@infradead.org Cc: rostedt@goodmis.org Cc: Valdis.Kletnieks@vt.edu Cc: dhowells@redhat.com LKML-Reference: <1266887105-1528-12-git-send-email-paulmck@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar --- diff --git a/security/keys/gc.c b/security/keys/gc.c index 4770be3..1990231 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c @@ -77,7 +77,8 @@ static bool key_gc_keyring(struct key *keyring, time_t limit) goto dont_gc; /* scan the keyring looking for dead keys */ - klist = rcu_dereference(keyring->payload.subscriptions); + klist = rcu_dereference_check(keyring->payload.subscriptions, + lockdep_is_held(&key_serial_lock)); if (!klist) goto dont_gc; diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 8ec0274..e814d21 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -151,7 +151,9 @@ static void keyring_destroy(struct key *keyring) write_unlock(&keyring_name_lock); } - klist = rcu_dereference(keyring->payload.subscriptions); + klist = rcu_dereference_check(keyring->payload.subscriptions, + rcu_read_lock_held() || + atomic_read(&keyring->usage) == 0); if (klist) { for (loop = klist->nkeys - 1; loop >= 0; loop--) key_put(klist->keys[loop]);