From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D05BAC433E2 for ; Fri, 11 Sep 2020 15:24:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 818EE2076C for ; Fri, 11 Sep 2020 15:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599837889; bh=ybDPXSWX6t6Yrp5Uds0fPcMTpwzBemoFk3ybMUuZEyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QZZ90CqIXMpPnmPa47AZv8LgPg9e5fyZAMpdVU8F3veLQQGJa7iW6nVtdnC1qaECC 6E7gmTH5THhrzNulhF/4hzyZW6oYR9qaJvJ5u/qVcmaZ5liBKd6kFNUdxIjj4134DR T5XTqU4t2K0PZDaOB4ktxsqOE34N1aRwwTjC5fZA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbgIKPYn (ORCPT ); Fri, 11 Sep 2020 11:24:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:53392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbgIKPRi (ORCPT ); Fri, 11 Sep 2020 11:17:38 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D03122456; Fri, 11 Sep 2020 12:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829181; bh=ybDPXSWX6t6Yrp5Uds0fPcMTpwzBemoFk3ybMUuZEyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1M/FByuPrgNq1JusDVuk1YhRm/doUstz9Ea9u/uS4/HHmulwV7a7t78H2gKn3SS4e IiSqSKDY8PuiAkh43pW8Ea6+ZwGX8hF6zSnP2ICrRynkgC8wrzBSdZhhZ7fa1nS3U1 oGplK8zKCSVpBZ/UfsUuR/vN95PGSdnB/cGyZDJw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Maloy , Tuong Lien , "David S. Miller" Subject: [PATCH 5.8 14/16] tipc: fix using smp_processor_id() in preemptible Date: Fri, 11 Sep 2020 14:47:31 +0200 Message-Id: <20200911122500.284435224@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122459.585735377@linuxfoundation.org> References: <20200911122459.585735377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tuong Lien [ 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 Signed-off-by: Tuong Lien Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/crypto.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/net/tipc/crypto.c +++ b/net/tipc/crypto.c @@ -326,7 +326,8 @@ static void tipc_aead_free(struct rcu_he 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 t */ 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; } /**