Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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>

authored by

Tuong Lien and committed by
David S. Miller
bb8872a1 c8146fe2

+9 -3
+9 -3
net/tipc/crypto.c
··· 326 326 if (aead->cloned) { 327 327 tipc_aead_put(aead->cloned); 328 328 } else { 329 - head = *this_cpu_ptr(aead->tfm_entry); 329 + head = *get_cpu_ptr(aead->tfm_entry); 330 + put_cpu_ptr(aead->tfm_entry); 330 331 list_for_each_entry_safe(tfm_entry, tmp, &head->list, list) { 331 332 crypto_free_aead(tfm_entry->tfm); 332 333 list_del(&tfm_entry->list); ··· 400 399 */ 401 400 static struct crypto_aead *tipc_aead_tfm_next(struct tipc_aead *aead) 402 401 { 403 - struct tipc_tfm **tfm_entry = this_cpu_ptr(aead->tfm_entry); 402 + struct tipc_tfm **tfm_entry; 403 + struct crypto_aead *tfm; 404 404 405 + tfm_entry = get_cpu_ptr(aead->tfm_entry); 405 406 *tfm_entry = list_next_entry(*tfm_entry, list); 406 - return (*tfm_entry)->tfm; 407 + tfm = (*tfm_entry)->tfm; 408 + put_cpu_ptr(tfm_entry); 409 + 410 + return tfm; 407 411 } 408 412 409 413 /**