linux-kernel.vger.kernel.org archive mirror
 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, Lars Persson <larper@axis.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.0 73/93] crypto: axis - fix for recursive locking from bottom half
Date: Thu, 18 Apr 2019 19:57:51 +0200	[thread overview]
Message-ID: <20190418160444.556108361@linuxfoundation.org> (raw)
In-Reply-To: <20190418160436.781762249@linuxfoundation.org>

[ Upstream commit c34a83820f59bb275e5f2d55cd5ea99c64f6ef23 ]

Clients may submit a new requests from the completion callback
context. The driver was not prepared to receive a request in this
state because it already held the request queue lock and a recursive
lock error is triggered.

Now all completions are queued up until we are ready to drop the queue
lock and then delivered.

The fault was triggered by TCP over an IPsec connection in the LTP
test suite:
  LTP: starting tcp4_ipsec02 (tcp_ipsec.sh -p ah -m transport -s "100 1000 65535")
  BUG: spinlock recursion on CPU#1, genload/943
   lock: 0xbf3c3094, .magic: dead4ead, .owner: genload/943, .owner_cpu: 1
  CPU: 1 PID: 943 Comm: genload Tainted: G           O    4.9.62-axis5-devel #6
  Hardware name: Axis ARTPEC-6 Platform
   (unwind_backtrace) from [<8010d134>] (show_stack+0x18/0x1c)
   (show_stack) from [<803a289c>] (dump_stack+0x84/0x98)
   (dump_stack) from [<8016e164>] (do_raw_spin_lock+0x124/0x128)
   (do_raw_spin_lock) from [<804de1a4>] (artpec6_crypto_submit+0x2c/0xa0)
   (artpec6_crypto_submit) from [<804def38>] (artpec6_crypto_prepare_submit_hash+0xd0/0x54c)
   (artpec6_crypto_prepare_submit_hash) from [<7f3165f0>] (ah_output+0x2a4/0x3dc [ah4])
   (ah_output [ah4]) from [<805df9bc>] (xfrm_output_resume+0x178/0x4a4)
   (xfrm_output_resume) from [<805d283c>] (xfrm4_output+0xac/0xbc)
   (xfrm4_output) from [<80587928>] (ip_queue_xmit+0x140/0x3b4)
   (ip_queue_xmit) from [<805a13b4>] (tcp_transmit_skb+0x4c4/0x95c)
   (tcp_transmit_skb) from [<8059f218>] (tcp_rcv_state_process+0xdf4/0xdfc)
   (tcp_rcv_state_process) from [<805a7530>] (tcp_v4_do_rcv+0x64/0x1ac)
   (tcp_v4_do_rcv) from [<805a9724>] (tcp_v4_rcv+0xa34/0xb74)
   (tcp_v4_rcv) from [<80581d34>] (ip_local_deliver_finish+0x78/0x2b0)
   (ip_local_deliver_finish) from [<8058259c>] (ip_local_deliver+0xe4/0x104)
   (ip_local_deliver) from [<805d23ec>] (xfrm4_transport_finish+0xf4/0x144)
   (xfrm4_transport_finish) from [<805df564>] (xfrm_input+0x4f4/0x74c)
   (xfrm_input) from [<804de420>] (artpec6_crypto_task+0x208/0x38c)
   (artpec6_crypto_task) from [<801271b0>] (tasklet_action+0x60/0xec)
   (tasklet_action) from [<801266d4>] (__do_softirq+0xcc/0x3a4)
   (__do_softirq) from [<80126d20>] (irq_exit+0xf4/0x15c)
   (irq_exit) from [<801741e8>] (__handle_domain_irq+0x68/0xbc)
   (__handle_domain_irq) from [<801014f0>] (gic_handle_irq+0x50/0x94)
   (gic_handle_irq) from [<80657370>] (__irq_usr+0x50/0x80)

Signed-off-by: Lars Persson <larper@axis.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/crypto/axis/artpec6_crypto.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
index f3442c2bdbdc..3c70004240d6 100644
--- a/drivers/crypto/axis/artpec6_crypto.c
+++ b/drivers/crypto/axis/artpec6_crypto.c
@@ -284,6 +284,7 @@ enum artpec6_crypto_hash_flags {
 
 struct artpec6_crypto_req_common {
 	struct list_head list;
+	struct list_head complete_in_progress;
 	struct artpec6_crypto_dma_descriptors *dma;
 	struct crypto_async_request *req;
 	void (*complete)(struct crypto_async_request *req);
@@ -2045,7 +2046,8 @@ static int artpec6_crypto_prepare_aead(struct aead_request *areq)
 	return artpec6_crypto_dma_map_descs(common);
 }
 
-static void artpec6_crypto_process_queue(struct artpec6_crypto *ac)
+static void artpec6_crypto_process_queue(struct artpec6_crypto *ac,
+	    struct list_head *completions)
 {
 	struct artpec6_crypto_req_common *req;
 
@@ -2056,7 +2058,7 @@ static void artpec6_crypto_process_queue(struct artpec6_crypto *ac)
 		list_move_tail(&req->list, &ac->pending);
 		artpec6_crypto_start_dma(req);
 
-		req->req->complete(req->req, -EINPROGRESS);
+		list_add_tail(&req->complete_in_progress, completions);
 	}
 
 	/*
@@ -2086,6 +2088,11 @@ static void artpec6_crypto_task(unsigned long data)
 	struct artpec6_crypto *ac = (struct artpec6_crypto *)data;
 	struct artpec6_crypto_req_common *req;
 	struct artpec6_crypto_req_common *n;
+	struct list_head complete_done;
+	struct list_head complete_in_progress;
+
+	INIT_LIST_HEAD(&complete_done);
+	INIT_LIST_HEAD(&complete_in_progress);
 
 	if (list_empty(&ac->pending)) {
 		pr_debug("Spurious IRQ\n");
@@ -2119,19 +2126,30 @@ static void artpec6_crypto_task(unsigned long data)
 
 		pr_debug("Completing request %p\n", req);
 
-		list_del(&req->list);
+		list_move_tail(&req->list, &complete_done);
 
 		artpec6_crypto_dma_unmap_all(req);
 		artpec6_crypto_copy_bounce_buffers(req);
 
 		ac->pending_count--;
 		artpec6_crypto_common_destroy(req);
-		req->complete(req->req);
 	}
 
-	artpec6_crypto_process_queue(ac);
+	artpec6_crypto_process_queue(ac, &complete_in_progress);
 
 	spin_unlock_bh(&ac->queue_lock);
+
+	/* Perform the completion callbacks without holding the queue lock
+	 * to allow new request submissions from the callbacks.
+	 */
+	list_for_each_entry_safe(req, n, &complete_done, list) {
+		req->complete(req->req);
+	}
+
+	list_for_each_entry_safe(req, n, &complete_in_progress,
+				 complete_in_progress) {
+		req->req->complete(req->req, -EINPROGRESS);
+	}
 }
 
 static void artpec6_crypto_complete_crypto(struct crypto_async_request *req)
-- 
2.19.1




  parent reply	other threads:[~2019-04-18 18:12 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18 17:56 [PATCH 5.0 00/93] 5.0.9-stable review Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 01/93] ARC: u-boot args: check that magic number is correct Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 02/93] arc: hsdk_defconfig: Enable CONFIG_BLK_DEV_RAM Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 03/93] inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch() Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 04/93] perf/core: Restore mmap record type correctly Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 05/93] perf data: Dont store auxtrace index for directory data file Greg Kroah-Hartman
2019-04-18 19:28   ` Thomas Backlund
2019-04-19 13:25     ` Sasha Levin
2019-04-20  8:48       ` Jiri Olsa
2019-04-18 19:29   ` Dan Rue
2019-04-18 17:56 ` [PATCH 5.0 06/93] mips: bcm47xx: Enable USB power on Netgear WNDR3400v2 Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 07/93] ext4: avoid panic during forced reboot Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 08/93] ext4: add missing brelse() in add_new_gdb_meta_bg() Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 09/93] ext4: report real fs size after failed resize Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 10/93] ALSA: echoaudio: add a check for ioremap_nocache Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 11/93] ALSA: sb8: add a check for request_region Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 12/93] auxdisplay: hd44780: Fix memory leak on ->remove() Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 13/93] drm/udl: use drm_gem_object_put_unlocked Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 14/93] IB/mlx4: Fix race condition between catas error reset and aliasguid flows Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 15/93] i40iw: Avoid panic when handling the inetdev event Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 16/93] mmc: davinci: remove extraneous __init annotation Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 17/93] ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 18/93] paride/pf: cleanup queues when detection fails Greg Kroah-Hartman
2019-04-19  7:13   ` nobuhiro1.iwamatsu
2019-04-19 13:30     ` Sasha Levin
2019-04-18 17:56 ` [PATCH 5.0 19/93] paride/pcd: " Greg Kroah-Hartman
2019-04-19  7:13   ` nobuhiro1.iwamatsu
2019-04-19 13:32     ` Sasha Levin
2019-04-18 17:56 ` [PATCH 5.0 20/93] thermal/intel_powerclamp: fix __percpu declaration of worker_data Greg Kroah-Hartman
2019-04-18 17:56 ` [PATCH 5.0 21/93] thermal: samsung: Fix incorrect check after code merge Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 22/93] thermal: bcm2835: Fix crash in bcm2835_thermal_debugfs Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 23/93] thermal/int340x_thermal: Add additional UUIDs Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 24/93] thermal/int340x_thermal: fix mode setting Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 25/93] thermal/intel_powerclamp: fix truncated kthread name Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 26/93] scsi: iscsi: flush running unbind operations when removing a session Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 27/93] sched/cpufreq: Fix 32-bit math overflow Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 28/93] sched/core: Fix buffer overflow in cgroup2 property cpu.max Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 29/93] x86/mm: Dont leak kernel addresses Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 30/93] tools/power turbostat: return the exit status of a command Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 31/93] scsi: core: Also call destroy_rcu_head() for passthrough requests Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 32/93] scsi: qla2xxx: Fix NULL pointer crash due to stale CPUID Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 33/93] perf stat: Fix --no-scale Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 34/93] perf list: Dont forget to drop the reference to the allocated thread_map Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 35/93] perf tools: Fix errors under optimization level -Og Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 36/93] perf config: Fix an error in the config template documentation Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 37/93] perf config: Fix a memory leak in collect_config() Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 38/93] perf build-id: Fix memory leak in print_sdt_events() Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 39/93] perf top: Delete the evlist before perf_session, fixing heap-use-after-free issue Greg Kroah-Hartman
2019-04-18 19:31   ` Dan Rue
2019-04-19 13:35     ` Sasha Levin
2019-04-18 19:33   ` Thomas Backlund
2019-04-18 17:57 ` [PATCH 5.0 40/93] perf top: Fix error handling in cmd_top() Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 41/93] perf hist: Add missing map__put() in error case Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 42/93] perf map: Remove map from names tree in __maps__remove() Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 43/93] perf maps: Purge all maps from the names tree Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 44/93] perf top: Fix global-buffer-overflow issue Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 45/93] perf evsel: Free evsel->counts in perf_evsel__exit() Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 46/93] perf tests: Fix a memory leak of cpu_map object in the openat_syscall_event_on_all_cpus test Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 47/93] perf tests: Fix memory leak by expr__find_other() in test__expr() Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 48/93] perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test() Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 49/93] ACPI / utils: Drop reference in test for device presence Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 50/93] PM / Domains: Avoid a potential deadlock Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 51/93] blk-iolatency: #include "blk.h" Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 52/93] drm/exynos/mixer: fix MIXER shadow registry synchronisation code Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 53/93] irqchip/stm32: Dont clear rising/falling config registers at init Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 54/93] irqchip/stm32: Dont set rising configuration " Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 55/93] irqchip/mbigen: Dont clear eventid when freeing an MSI Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 56/93] x86/hpet: Prevent potential NULL pointer dereference Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 57/93] x86/hyperv: " Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 58/93] x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 59/93] drm/nouveau/debugfs: Fix check of pm_runtime_get_sync failure Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 60/93] iommu/vt-d: Check capability before disabling protected memory Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 61/93] iommu/vt-d: Save the right domain ID used by hardware Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 62/93] x86/hw_breakpoints: Make default case in hw_breakpoint_arch_parse() return an error Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 63/93] cifs: fix that return -EINVAL when do dedupe operation Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 64/93] fix incorrect error code mapping for OBJECTID_NOT_FOUND Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 65/93] cifs: Fix slab-out-of-bounds when tracing SMB tcon Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 66/93] x86/gart: Exclude GART aperture from kcore Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 67/93] ext4: prohibit fstrim in norecovery mode Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 68/93] lkdtm: Print real addresses Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 69/93] lkdtm: Add tests for NULL pointer dereference Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 70/93] drm/amdgpu: psp_ring_destroy cause psp->km_ring.ring_mem NULL Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 71/93] drm/panel: panel-innolux: set display off in innolux_panel_unprepare Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 72/93] net: hns3: Fix NULL deref when unloading driver Greg Kroah-Hartman
2019-04-18 17:57 ` Greg Kroah-Hartman [this message]
2019-04-18 17:57 ` [PATCH 5.0 74/93] Revert "ACPI / EC: Remove old CLEAR_ON_RESUME quirk" Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 75/93] RDMA/hns: Fix the Oops during rmmod or insmod ko when reset occurs Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 76/93] coresight: cpu-debug: Support for CA73 CPUs Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 77/93] PCI: Blacklist power management of Gigabyte X299 DESIGNARE EX PCIe ports Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 78/93] PCI/ASPM: Save LTR Capability for suspend/resume Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 79/93] f2fs: sync filesystem after roll-forward recovery Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 80/93] drm/nouveau/volt/gf117: fix speedo readout register Greg Kroah-Hartman
2019-04-18 17:57 ` [PATCH 5.0 81/93] platform/x86: intel_pmc_core: Quirk to ignore XTAL shutdown Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 82/93] ARM: 8839/1: kprobe: make patch_lock a raw_spinlock_t Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 83/93] drm/amdkfd: use init_mqd function to allocate object for hid_mqd (CI) Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 84/93] appletalk: Fix use-after-free in atalk_proc_exit Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 85/93] cifs: return -ENODATA when deleting an xattr that does not exist Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 86/93] lib/div64.c: off by one in shift Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 87/93] rxrpc: Fix client call connect/disconnect race Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 88/93] f2fs: fix to dirty inode for i_mode recovery Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 89/93] f2fs: fix to use kvfree instead of kzfree Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 90/93] f2fs: fix to add refcount once page is tagged PG_private Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 91/93] include/linux/swap.h: use offsetof() instead of custom __swapoffset macro Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 92/93] bpf: fix use after free in bpf_evict_inode Greg Kroah-Hartman
2019-04-18 17:58 ` [PATCH 5.0 93/93] IB/hfi1: Failed to drain send queue when QP is put into error state Greg Kroah-Hartman
2019-04-19 10:08 ` [PATCH 5.0 00/93] 5.0.9-stable review Jon Hunter
2019-04-20 14:40   ` Greg Kroah-Hartman
2019-04-19 14:24 ` shuah
2019-04-20  7:05   ` Greg Kroah-Hartman
2019-04-19 19:41 ` Guenter Roeck
2019-04-19 21:00   ` Guenter Roeck
2019-04-20  7:05     ` Greg Kroah-Hartman
2019-04-20  4:52 ` Naresh Kamboju
2019-04-20 14:41   ` Greg Kroah-Hartman
2019-04-20 12:28 ` Bharath Vedartham
2019-04-20 14:41   ` 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=20190418160444.556108361@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=larper@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).