All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Jon Maloy <jmaloy@redhat.com>,
	Tuong Lien <tuong.t.lien@dektech.com.au>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 5.8 14/16] tipc: fix using smp_processor_id() in preemptible
Date: Fri, 11 Sep 2020 14:47:31 +0200	[thread overview]
Message-ID: <20200911122500.284435224@linuxfoundation.org> (raw)
In-Reply-To: <20200911122459.585735377@linuxfoundation.org>

From: Tuong Lien <tuong.t.lien@dektech.com.au>

[ 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>
---
 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;
 }
 
 /**



  parent reply	other threads:[~2020-09-11 15:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 12:47 [PATCH 5.8 00/16] 5.8.9-rc1 review Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 01/16] io_uring: fix cancel of deferred reqs with ->files Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 02/16] io_uring: fix linked deferred ->files cancellation Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 03/16] RDMA/cma: Simplify DEVICE_REMOVAL for internal_id Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 04/16] RDMA/cma: Using the standard locking pattern when delivering the removal event Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 05/16] RDMA/cma: Remove unneeded locking for req paths Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 06/16] RDMA/cma: Execute rdma_cm destruction from a handler properly Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 07/16] ipv4: Silence suspicious RCU usage warning Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 08/16] ipv6: Fix sysctl max for fib_multipath_hash_policy Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 09/16] netlabel: fix problems with mapping removal Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 10/16] net: usb: dm9601: Add USB ID of Keenetic Plus DSL Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 11/16] sctp: not disable bh in the whole sctp_get_port_local() Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 12/16] taprio: Fix using wrong queues in gate mask Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 13/16] tipc: fix shutdown() of connectionless socket Greg Kroah-Hartman
2020-09-11 12:47 ` Greg Kroah-Hartman [this message]
2020-09-11 12:47 ` [PATCH 5.8 15/16] net: disable netpoll on fresh napis Greg Kroah-Hartman
2020-09-11 12:47 ` [PATCH 5.8 16/16] mptcp: free acked data before waiting for more memory Greg Kroah-Hartman
2020-09-11 17:10 ` [PATCH 5.8 00/16] 5.8.9-rc1 review Jon Hunter
2020-09-12 12:44   ` Greg Kroah-Hartman
2020-09-11 22:19 ` Shuah Khan
2020-09-12 12:44   ` Greg Kroah-Hartman
2020-09-12  2:19 ` Guenter Roeck
2020-09-12 12:44   ` Greg Kroah-Hartman
2020-09-12  7:27 ` Naresh Kamboju
2020-09-12 12:44   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200911122500.284435224@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=jmaloy@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tuong.t.lien@dektech.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.