mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nate Eldredge <nate@thatsmathematics.com>
To: linux-kernel@vger.kernel.org
Cc: Maarten Baert <maarten-baert@hotmail.com>
Subject: math_state_restore and kernel_fpu_end disable interrupts?
Date: Fri, 17 Jan 2014 23:15:17 -0700 (MST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1401172242390.2906@minerva.lan> (raw)

In trying to track down a bug (see below), I noticed that 
math_state_restore() in arch/x86/kernel/traps.c appears to unconditionally 
disable interrupts when called.  Is this intended behavior or a bug?

The bug in question is triggered by dumping core on an ecryptfs file 
system when aesni-intel is loaded.  (See 
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1265841 for the 
original report.)  The symptom is that __find_get_block() gets called with 
interrupts disabled, causing a BUG().  I tried to find where interrupts 
were getting disabled and wound up in aes_set_key_common() in 
arch/x86/crypto/aesni-intel_glue.c.  It calls aesni_set_key(), and since 
that uses the FPU, it wraps it in kernel_fpu_begin()/kernel_fpu_end(). 
But kernel_fpu_end() calls math_state_restore() which disables interrupts. 
I've verified that interrupts are still enabled just before the call to 
kernel_fpu_end().

math_state_restore() does:

local_irq_enable();
init_fpu(tsk);
local_irq_disable();

with the result that interrupts are disabled when it finishes, even if 
they were enabled to begin with.  That looks strange to me; are we sure it 
shouldn't just save and restore the interrupt flag?  Or are we not 
supposed to call it with interrupts enabled?

Given the intimidating comment preceding math_state_restore() ("Don't 
touch unless you *really* know how it works"), it's entirely possible I am 
missing something...

Any suggestions appreciated.  Thanks!

-- 
Nate Eldredge
nate@thatsmathematics.com


             reply	other threads:[~2014-01-18  6:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-18  6:15 Nate Eldredge [this message]
2014-01-19 11:35 George Spelvin
2014-01-19 19:02 ` Nate Eldredge
2014-01-19 21:02   ` George Spelvin
2014-01-21  2:22     ` Nate Eldredge
2014-01-21 13:58       ` Jan Kara
2014-01-21 17:10       ` George Spelvin
2014-01-28 18:53     ` George Spelvin
2014-01-28 19:23       ` Nate Eldredge

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=alpine.DEB.2.10.1401172242390.2906@minerva.lan \
    --to=nate@thatsmathematics.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten-baert@hotmail.com \
    /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

all inboxes | Powered by JetHome®