diff options
author | Tuong Lien <tuong.t.lien@dektech.com.au> | 2020-08-30 02:37:55 +0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-09-12 14:22:14 +0200 |
commit | 6f0e276cda3e452d634b05070fd23a5ef7e6d0a4 (patch) | |
tree | 8077278629bcfc06d1b45f78cd93c2e372f034d2 | |
parent | aae250a268933d6eb4a7454e96abeb9c9a85fc04 (diff) | |
download | linux-stable-6f0e276cda3e452d634b05070fd23a5ef7e6d0a4.tar.gz linux-stable-6f0e276cda3e452d634b05070fd23a5ef7e6d0a4.tar.bz2 linux-stable-6f0e276cda3e452d634b05070fd23a5ef7e6d0a4.zip |
tipc: fix using smp_processor_id() in preemptible
[ Upstream commit bb8872a1e6bc911869a729240781076ed950764b ]
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: fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")
Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/tipc/crypto.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c index d6426b6cc9c5..3f35577b7404 100644 --- a/net/tipc/crypto.c +++ b/net/tipc/crypto.c @@ -326,7 +326,8 @@ static void tipc_aead_free(struct rcu_head *rp) if (aead->cloned) { tipc_aead_put(aead->cloned); } 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) { crypto_free_aead(tfm_entry->tfm); list_del(&tfm_entry->list); @@ -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) { - 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); - return (*tfm_entry)->tfm; + tfm = (*tfm_entry)->tfm; + put_cpu_ptr(tfm_entry); + + return tfm; } /** |