Skip to content

Commit

Permalink
encrypted-keys: fix rcu and sparse messages
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Mimi Zohar <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
Mimi Zohar authored and James Morris committed Jan 17, 2012
1 parent ee0b31a commit 6ac6172
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion security/keys/encrypted-keys/encrypted.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion security/keys/encrypted-keys/masterkey_trusted.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6ac6172

Please sign in to comment.