From: Mike Snitzer <snitzer@redhat.com>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>, Neil Brown <neilb@suse.de>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
dm-devel@redhat.com, linux-raid@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation
Date: Thu, 9 Apr 2015 10:26:58 -0400 [thread overview]
Message-ID: <20150409142658.GA9839@redhat.com> (raw)
In-Reply-To: <20150409141633.GJ12339@atrey.karlin.mff.cuni.cz>
On Thu, Apr 09 2015 at 10:16am -0400,
Pali Rohár <pali.rohar@gmail.com> wrote:
> On Thursday 09 April 2015 10:08:43 Mike Snitzer wrote:
> > On Thu, Apr 09 2015 at 9:28am -0400,
> > Pali Rohár <pali.rohar@gmail.com> wrote:
> >
> > > On Thursday 09 April 2015 09:12:08 Mike Snitzer wrote:
> > > > On Mon, Apr 06 2015 at 9:29am -0400,
> > > > Pali Rohár <pali.rohar@gmail.com> wrote:
> > > >
> > > > > On Monday 06 April 2015 15:00:46 Mike Snitzer wrote:
> > > > > > On Sun, Apr 05 2015 at 1:20pm -0400,
> > > > > >
> > > > > > Pali Rohár <pali.rohar@gmail.com> wrote:
> > > > > > > This patch series increase security of suspend and hibernate
> > > > > > > actions. It allows user to safely wipe crypto keys before
> > > > > > > suspend and hibernate actions starts without race
> > > > > > > conditions on userspace process with heavy I/O.
> > > > > > >
> > > > > > > To automatically wipe cryto key for <device> before
> > > > > > > hibernate action call: $ dmsetup message <device> 0 key
> > > > > > > wipe_on_hibernation 1
> > > > > > >
> > > > > > > To automatically wipe cryto key for <device> before suspend
> > > > > > > action call: $ dmsetup message <device> 0 key
> > > > > > > wipe_on_suspend 1
> > > > > > >
> > > > > > > (Value 0 after wipe_* string reverts original behaviour - to
> > > > > > > not wipe key)
> > > > > >
> > > > > > Can you elaborate on the attack vector your changes are meant
> > > > > > to protect against? The user already authorized access, why
> > > > > > is it inherently dangerous to _not_ wipe the associated key
> > > > > > across these events?
> > > > >
> > > > > Hi,
> > > > >
> > > > > yes, I will try to explain current problems with cryptsetup
> > > > > luksSuspend command and hibernation.
> > > > >
> > > > > First, sometimes it is needed to put machine into other hands.
> > > > > You can still watch other person what is doing with machine, but
> > > > > once if you let machine unlocked (e.g opened luks disk), she/he
> > > > > can access encrypted data.
> > > > >
> > > > > If you turn off machine, it could be safe, because luks disk
> > > > > devices are locked. But if you enter machine into suspend or
> > > > > hibernate state luks devices are still open. And my patches try
> > > > > to achieve similar security as when machine is off (= no crypto
> > > > > keys in RAM or on swap).
> > > > >
> > > > > When doing hibernate on unencrypted swap it is to prevent leaking
> > > > > crypto keys to hibernate image (which is stored in swap).
> > > > >
> > > > > When doing suspend action it is again to prevent leaking crypto
> > > > > keys. E.g when you suspend laptop and put it off (somebody can
> > > > > remove RAMs and do some cold boot attack).
> > > > >
> > > > > The most common situation is:
> > > > > You have mounted partition from dm-crypt device (e.g. /home/),
> > > > > some userspace processes access it (e.g opened firefox which
> > > > > still reads/writes to cache ~/.firefox/) and you want to drop
> > > > > crypto keys from kernel for some time.
> > > > >
> > > > > For that operation there is command cryptsetup luksSuspend, which
> > > > > suspend dm device and then tell kernel to wipe crypto keys. All
> > > > > I/O operations are then stopped and userspace processes which
> > > > > want to do some those I/O operations are stopped too (until you
> > > > > call cryptsetup luksResume and enter correct key).
> > > > >
> > > > > Now if you want to suspend/hiberate your machine (when some of dm
> > > > > devices are suspeneded and some processes are stopped due to
> > > > > pending I/O) it is not possible. Kernel freeze_processes function
> > > > > will fail because userspace processes are still stopped inside
> > > > > some I/O syscall (read/write, etc,...).
> > > > >
> > > > > My patches fixes this problem and do those operations (suspend dm
> > > > > device, wipe crypto keys, enter suspend/hiberate) in correct
> > > > > order and without race condition.
> > > > >
> > > > > dm device is suspended *after* userspace processes are freezed
> > > > > and after that are crypto keys wiped. And then computer/laptop
> > > > > enters into suspend/hibernate state.
> > > >
> > > > Wouldn't it be better to fix freeze_processes() to be tolerant of
> > > > processes that are hung as a side-effect of their backing storage being
> > > > suspended? A hibernate shouldn't fail simply because a user chose to
> > > > suspend a DM device.
> > > >
> > > > Then this entire problem goes away and the key can be wiped from
> > > > userspace (like you said above).
> > >
> > > Still there will be race condition. Before hibernation (and device
> > > poweroff) we should have synced disks and filesystems to prevent data
> > > lose (or other damage) as more as we can. And if there will be some
> > > application which using lot of I/O (e.g normal firefox) then there
> > > always will be race condtion.
> >
> > The DM suspend will take care of flushing any pending I/O. So I don't
> > see where the supposed race is...
> >
>
> Any I/O operation after DM suspend is race condition and could cause
> data lost.
>
> > Anything else that is trapped in userspace memory will be there when the
> > machine resumes.
> >
>
> You are expecting that machine resumes always at 100% and correctly. But
> this is not truth in real world. There are planty of users who reported
> lot of random problems with suspend or hibernate...
But the system was left in a crash consistent state. Properly written
apps will wait for I/O to ensure data loss (in the event of a failed
resume) isn't a problem.
> > > So proper way is to wipe luks crypto keys *after* userspace processes
> > > are freezed.
> >
> > I know you believe that I'm just not accepting that at face value.
>
> If disks are synced before any DM suspend operation then we have higher
> chance of preventing data corruption.
disks are already synced as part of the DM suspend operation!
But you're saying that all user processes are frozen (and associated
I/O flushed) before the DM suspend, that is different:
> I still think that correct order is only:
>
> * freeze processes (which doing continous I/O)
> * fs & disk sync
> * DM suspend
> * wipe crypto keys
> * enter hibernate
I just don't think that extreme is _required_ to have a hibernate/resume
that incorporates dm-crypt key wiping.
next prev parent reply other threads:[~2015-04-09 14:27 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-05 17:20 [PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-04-05 17:20 ` [PATCH 1/3] PM suspend/hibernate: Call notifier after freezing processes Pali Rohár
2015-04-09 0:28 ` Rafael J. Wysocki
2015-04-09 6:36 ` Pali Rohár
2015-04-09 17:13 ` Rafael J. Wysocki
2015-04-09 16:55 ` Pali Rohár
2015-04-05 17:20 ` [PATCH 2/3] dm: Export function dm_suspend_md() Pali Rohár
2015-04-05 17:20 ` [PATCH 3/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-04-07 13:55 ` [dm-devel] " Alasdair G Kergon
2015-04-06 13:00 ` [PATCH 0/3] " Mike Snitzer
2015-04-06 13:25 ` Pavel Machek
2015-04-06 20:51 ` Mike Snitzer
2015-04-06 21:13 ` Why wipe crypto keys during suspend (was Re: [PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation) Pavel Machek
2015-04-06 13:29 ` [PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-04-06 18:17 ` Pavel Machek
2015-04-06 21:27 ` Pali Rohár
2015-04-09 13:12 ` Mike Snitzer
2015-04-09 13:28 ` Pali Rohár
2015-04-09 14:08 ` Mike Snitzer
2015-04-09 14:16 ` Pali Rohár
2015-04-09 14:26 ` Mike Snitzer [this message]
2015-04-09 14:38 ` Pali Rohár
2015-04-14 6:50 ` Pavel Machek
2015-04-23 17:02 ` Pali Rohár
[not found] ` <mgnv2g$if5$2@ger.gmane.org>
2015-04-17 7:52 ` Mike Snitzer
2015-04-17 8:52 ` [dm-devel] " Ondrej Kozina
2015-04-17 15:53 ` Alex Elsayed
2015-04-14 6:41 ` Pavel Machek
2015-06-21 11:20 ` [PATCH v2 " Pali Rohár
2015-06-21 11:20 ` [PATCH v2 1/3] PM suspend/hibernate: Call notifier after freezing processes Pali Rohár
2015-07-16 1:02 ` Rafael J. Wysocki
2015-07-16 7:33 ` Pali Rohár
2015-07-17 23:27 ` Rafael J. Wysocki
2015-07-20 7:32 ` Pali Rohár
2015-07-20 21:46 ` Rafael J. Wysocki
2015-07-21 22:08 ` NeilBrown
2015-07-21 23:00 ` Rafael J. Wysocki
2015-07-21 23:03 ` Rafael J. Wysocki
2016-12-27 14:29 ` Pali Rohár
2015-06-21 11:20 ` [PATCH v2 2/3] dm: Export function dm_suspend_md() Pali Rohár
2015-07-17 14:04 ` Mike Snitzer
2015-07-17 14:22 ` Pali Rohár
2015-07-17 15:22 ` Mike Snitzer
2015-07-17 15:30 ` Mike Snitzer
2015-07-17 17:13 ` Pali Rohár
2015-07-17 17:31 ` Mike Snitzer
2015-06-21 11:20 ` [PATCH v2 3/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation Pali Rohár
2015-07-28 14:44 ` Pavel Machek
2015-07-28 14:48 ` Pali Rohár
2015-07-07 7:59 ` [PATCH v2 0/3] " Pali Rohár
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=20150409142658.GA9839@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
/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).