Commit ee0b31a2 authored by Mimi Zohar's avatar Mimi Zohar Committed by James Morris

keys: fix trusted/encrypted keys sparse rcu_assign_pointer messages

Define rcu_assign_keypointer(), which uses the key payload.rcudata instead
of payload.data, to resolve the CONFIG_SPARSE_RCU_POINTER message:
"incompatible types in comparison expression (different address spaces)"

Replace the rcu_assign_pointer() calls in encrypted/trusted keys with
rcu_assign_keypointer().
Signed-off-by: default avatarMimi Zohar <zohar@us.ibm.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent efde8b6e
...@@ -293,6 +293,9 @@ static inline bool key_is_instantiated(const struct key *key) ...@@ -293,6 +293,9 @@ static inline bool key_is_instantiated(const struct key *key)
(rcu_dereference_protected((KEY)->payload.rcudata, \ (rcu_dereference_protected((KEY)->payload.rcudata, \
rwsem_is_locked(&((struct key *)(KEY))->sem))) rwsem_is_locked(&((struct key *)(KEY))->sem)))
#define rcu_assign_keypointer(KEY, PAYLOAD) \
(rcu_assign_pointer((KEY)->payload.rcudata, PAYLOAD))
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
extern ctl_table key_sysctls[]; extern ctl_table key_sysctls[];
#endif #endif
......
...@@ -810,7 +810,7 @@ static int encrypted_instantiate(struct key *key, const void *data, ...@@ -810,7 +810,7 @@ static int encrypted_instantiate(struct key *key, const void *data,
goto out; goto out;
} }
rcu_assign_pointer(key->payload.data, epayload); rcu_assign_keypointer(key, epayload);
out: out:
kfree(datablob); kfree(datablob);
return ret; return ret;
...@@ -874,7 +874,7 @@ static int encrypted_update(struct key *key, const void *data, size_t datalen) ...@@ -874,7 +874,7 @@ static int encrypted_update(struct key *key, const void *data, size_t datalen)
memcpy(new_epayload->payload_data, epayload->payload_data, memcpy(new_epayload->payload_data, epayload->payload_data,
epayload->payload_datalen); epayload->payload_datalen);
rcu_assign_pointer(key->payload.data, new_epayload); rcu_assign_keypointer(key, new_epayload);
call_rcu(&epayload->rcu, encrypted_rcu_free); call_rcu(&epayload->rcu, encrypted_rcu_free);
out: out:
kfree(buf); kfree(buf);
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/err.h> #include <linux/err.h>
#include <keys/trusted-type.h> #include <keys/trusted-type.h>
#include <keys/encrypted-type.h>
#include "encrypted.h"
/* /*
* request_trusted_key - request the trusted key * request_trusted_key - request the trusted key
......
...@@ -993,7 +993,7 @@ static int trusted_instantiate(struct key *key, const void *data, ...@@ -993,7 +993,7 @@ static int trusted_instantiate(struct key *key, const void *data,
kfree(datablob); kfree(datablob);
kfree(options); kfree(options);
if (!ret) if (!ret)
rcu_assign_pointer(key->payload.data, payload); rcu_assign_keypointer(key, payload);
else else
kfree(payload); kfree(payload);
return ret; return ret;
...@@ -1067,7 +1067,7 @@ static int trusted_update(struct key *key, const void *data, size_t datalen) ...@@ -1067,7 +1067,7 @@ static int trusted_update(struct key *key, const void *data, size_t datalen)
goto out; goto out;
} }
} }
rcu_assign_pointer(key->payload.data, new_p); rcu_assign_keypointer(key, new_p);
call_rcu(&p->rcu, trusted_rcu_free); call_rcu(&p->rcu, trusted_rcu_free);
out: out:
kfree(datablob); kfree(datablob);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment