Commit bb8872a1 authored by Tuong Lien's avatar Tuong Lien Committed by David S. Miller

tipc: fix using smp_processor_id() in preemptible

The 'this_cpu_ptr()' is used to obtain the AEAD key' TFM on the current
CPU for encryption, however the execution can be preemptible since it's
actually user-space context, so the 'using smp_processor_id() in
preemptible' has been observed.

We fix the issue by using the 'get/put_cpu_ptr()' API which consists of
a 'preempt_disable()' instead.

Fixes: fc1b6d6d ("tipc: introduce TIPC encryption & authentication")
Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
Signed-off-by: default avatarTuong Lien <tuong.t.lien@dektech.com.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c8146fe2
...@@ -326,7 +326,8 @@ static void tipc_aead_free(struct rcu_head *rp) ...@@ -326,7 +326,8 @@ static void tipc_aead_free(struct rcu_head *rp)
if (aead->cloned) { if (aead->cloned) {
tipc_aead_put(aead->cloned); tipc_aead_put(aead->cloned);
} else { } else {
head = *this_cpu_ptr(aead->tfm_entry); head = *get_cpu_ptr(aead->tfm_entry);
put_cpu_ptr(aead->tfm_entry);
list_for_each_entry_safe(tfm_entry, tmp, &head->list, list) { list_for_each_entry_safe(tfm_entry, tmp, &head->list, list) {
crypto_free_aead(tfm_entry->tfm); crypto_free_aead(tfm_entry->tfm);
list_del(&tfm_entry->list); list_del(&tfm_entry->list);
...@@ -399,10 +400,15 @@ static void tipc_aead_users_set(struct tipc_aead __rcu *aead, int val) ...@@ -399,10 +400,15 @@ static void tipc_aead_users_set(struct tipc_aead __rcu *aead, int val)
*/ */
static struct crypto_aead *tipc_aead_tfm_next(struct tipc_aead *aead) static struct crypto_aead *tipc_aead_tfm_next(struct tipc_aead *aead)
{ {
struct tipc_tfm **tfm_entry = this_cpu_ptr(aead->tfm_entry); struct tipc_tfm **tfm_entry;
struct crypto_aead *tfm;
tfm_entry = get_cpu_ptr(aead->tfm_entry);
*tfm_entry = list_next_entry(*tfm_entry, list); *tfm_entry = list_next_entry(*tfm_entry, list);
return (*tfm_entry)->tfm; tfm = (*tfm_entry)->tfm;
put_cpu_ptr(tfm_entry);
return tfm;
} }
/** /**
......
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