encrypted-keys: fix rcu and sparse messages
authorMimi Zohar <zohar@linux.vnet.ibm.com>
Tue, 17 Jan 2012 20:40:02 +0000 (20:40 +0000)
committerJames Morris <jmorris@namei.org>
Tue, 17 Jan 2012 23:41:30 +0000 (10:41 +1100)
Enabling CONFIG_PROVE_RCU and CONFIG_SPARSE_RCU_POINTER resulted in
"suspicious rcu_dereference_check() usage!" and "incompatible types
in comparison expression (different address spaces)" messages.

Access the masterkey directly when holding the rwsem.

Changelog v1:
- Use either rcu_read_lock()/rcu_derefence_key()/rcu_read_unlock()
or remove the unnecessary rcu_derefence() - David Howells

Reported-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
security/keys/encrypted-keys/encrypted.c
security/keys/encrypted-keys/masterkey_trusted.c

index d91efb6901e93128ecae3dfd3cf2e0cefa7d1615..2d1bb8af7696d5d431394cfbe8ac6d5e40f24da2 100644 (file)
@@ -314,7 +314,7 @@ static struct key *request_user_key(const char *master_desc, u8 **master_key,
                goto error;
 
        down_read(&ukey->sem);
-       upayload = rcu_dereference(ukey->payload.data);
+       upayload = ukey->payload.data;
        *master_key = upayload->data;
        *master_keylen = upayload->datalen;
 error:
index 8c16c3e472e74a0b9e9f0a1070db8b3729b09891..013f7e5d3a2fce42d026fd87a4a0d6e94af1d53f 100644 (file)
@@ -39,7 +39,7 @@ struct key *request_trusted_key(const char *trusted_desc,
                goto error;
 
        down_read(&tkey->sem);
-       tpayload = rcu_dereference(tkey->payload.data);
+       tpayload = tkey->payload.data;
        *master_key = tpayload->key;
        *master_keylen = tpayload->key_len;
 error: