Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
To: Gurucharan Shetty <gurucharan.shetty@gmail.com>
Cc: linux-crypto <linux-crypto@vger.kernel.org>
Subject: [PATCH] Re: aesni intel and kernel crashes.
Date: Thu, 18 Oct 2012 14:52:49 +0300	[thread overview]
Message-ID: <20121018115249.22157.69385.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <CA+sc+0T3CFwv6JdcLA66=pD=6LcaQOJZnvDGqp3o4LKN85ZbZg@mail.gmail.com>

Does this patch help?

It applies cleanly to 3.2.x, if that version easier for you to reproduce the
issue.

...

cryptd_queue_worker attempts to prevent simultanious accesses to crypto-work
queue by cryptd_enqueue_request using preempt_disable/preempt_enable. However
cryptd_enqueue_request might be called from interrupt context, so add
local_irq_save/local_irq_restore to prevent data corruption and panics.
---
 crypto/cryptd.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 671d4d6..8f62d06 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -133,16 +133,23 @@ static int cryptd_enqueue_request(struct cryptd_queue *queue,
  * do. */
 static void cryptd_queue_worker(struct work_struct *work)
 {
+	unsigned long flags;
 	struct cryptd_cpu_queue *cpu_queue;
 	struct crypto_async_request *req, *backlog;
 
 	cpu_queue = container_of(work, struct cryptd_cpu_queue, work);
-	/* Only handle one request at a time to avoid hogging crypto
+	/*
+	 * Only handle one request at a time to avoid hogging crypto
 	 * workqueue. preempt_disable/enable is used to prevent
-	 * being preempted by cryptd_enqueue_request() */
+	 * being preempted by cryptd_enqueue_request(). local_irq_save/restore
+	 * is used to prevent cryptd_enqueue_request() being accessed from
+	 * interrupts.
+	 */
+	local_irq_save(flags);
 	preempt_disable();
 	backlog = crypto_get_backlog(&cpu_queue->queue);
 	req = crypto_dequeue_request(&cpu_queue->queue);
+	local_irq_restore(flags);
 	preempt_enable();
 
 	if (!req)

  parent reply	other threads:[~2012-10-18 11:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25 15:21 aesni intel and kernel crashes Gurucharan Shetty
2012-09-28 12:41 ` Jussi Kivilinna
2012-10-18 11:52 ` Jussi Kivilinna [this message]
2012-10-19 23:05   ` [PATCH] " Gurucharan Shetty

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=20121018115249.22157.69385.stgit@localhost6.localdomain6 \
    --to=jussi.kivilinna@mbnet.fi \
    --cc=gurucharan.shetty@gmail.com \
    --cc=linux-crypto@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