encrypt suspend data for easy wiping
Subsystems (2)
From: Andreas Steinmetz <[email protected]>
To prevent data gathering from swap after resume you can encrypt the suspend image with a temporary key that is deleted on resume. Note that the temporary key is stored unencrypted on disk while the system is suspended... still it means that saved data are wiped from disk during resume by simply overwritting the key.
---
commit b61ea835309d0fb87cf1c7a2d83d5832ae8eb116 tree 17bfb260d69819d29e84e481382aa090f0a15969 parent d676c816f71e27761f419d399ad6be728c97a4a9 author <pavel@amd.(none)> Sun, 03 Jul 2005 23:34:20 +0200 committer <pavel@amd.(none)> Sun, 03 Jul 2005 23:34:20 +0200
Documentation/power/swsusp.txt | 7 ++ kernel/power/Kconfig | 12 +++ kernel/power/main.c | 5 + kernel/power/swsusp.c | 148 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 168 insertions(+), 4 deletions(-)
Documentation/power/swsusp.txt +7 -0
@@ -30,6 +30,13 @@ echo shutdown > /sys/power/disk; echo di echo platform > /sys/power/disk; echo disk > /sys/power/state +Encrypted suspend image: +------------------------ +If you want to store your suspend image encrypted with a temporary +key to prevent data gathering after resume you must compile +crypto and the aes algorithm into the kernel - modules won't work +as they cannot be loaded at resume time. + Article about goals and implementation of Software Suspend for Linux ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/power/Kconfig +12 -0
@@ -76,3 +76,15 @@ config SUSPEND_SMP bool depends on HOTPLUG_CPU && X86 && PM default y + +config SWSUSP_ENCRYPT + bool "Encrypt suspend image" + depends on SOFTWARE_SUSPEND && CRYPTO=y && (CRYPTO_AES=y || CRYPTO_AES_586=y) + default "" + ---help--- + To prevent data gathering from swap after resume you can encrypt + the suspend image with a temporary key that is deleted on + resume. + + Note that the temporary key is stored unencrypted on disk while the + system is suspended.
kernel/power/main.c +3 -2
@@ -129,11 +129,12 @@ static void suspend_finish(suspend_state -static char * pm_states[] = { +static char * pm_states[PM_SUSPEND_MAX ] = { [PM_SUSPEND_STANDBY ] ="standby" , [PM_SUSPEND_MEM ] ="mem" , +#ifdef CONFIG_SOFTWARE_SUSPEND [PM_SUSPEND_DISK ] ="disk" , -NULL , +#endif };
kernel/power/swsusp.c +146 -2
242 lines not on this page · raw message
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Quoted 6 lines · Pavel Machek
To prevent data gathering from swap after resume you can encrypt the suspend image with a temporary key that is deleted on resume. Note that the temporary key is stored unencrypted on disk while the system is suspended... still it means that saved data are wiped from disk during resume by simply overwritting the key.
hm, how useful is that? swap can still contain sensitive userspace stuff.
Are there any plans to allow the user to type the key in on resume?
Documentation/power/swsusp.txt echo shutdown > /sys/power/disk; echo di · line 38
Quoted 6 lines
Documentation/power/swsusp.txt +6
-0+Encrypted suspend image: +------------------------ +If you want to store your suspend image encrypted with a temporary +key to prevent data gathering after resume you must compile +crypto and the aes algorithm into the kernel - modules won't work +as they cannot be loaded at resume time.
Why not just `select' the needed symbols in Kconfig? It makes configuration much easier for the user.
kernel/power/swsusp.c static struct swsusp_info swsusp_info; · line 173
Quoted 3 lines
kernel/power/swsusp.c +3
-0+if (!*tfm) { +if (sizeof (key) <crypto_tfm_alg_min_keysize (*tfm)) { +if (mode) {
Coding style nit: please use a single space after `if'.
kernel/power/swsusp.c static struct swsusp_info swsusp_info; · line 201
Quoted 2 lines
kernel/power/swsusp.c +2
-0+fail:crypto_free_tfm (*tfm); +out:return error;
We conventionally insert a newline directly after labels.
Review
Quoted 9 lines
(quoted diff) +9
-0+#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT
err, no. Please find a way to reduce the ifdeffery.
Hi!
Quoted 8 lines
Quoted 5 lines
To prevent data gathering from swap after resume you can encrypt the suspend image with a temporary key that is deleted on resume. Note that the temporary key is stored unencrypted on disk while the system is suspended... still it means that saved data are wiped from disk during resume by simply overwritting the key.
hm, how useful is that? swap can still contain sensitive userspace stuff.
At least userspace has chance to mark *really* sensitive stuff as unswappable. Unfortunately that does not work against swsusp :-(.
[BTW... I was thinking about just generating random key on swapon, and using it, so that data in swap is garbage after reboot; no userspace changes needed. What do you think?]
Quoted 1 line
Are there any plans to allow the user to type the key in on resume?
Plans... ;-).
Quoted 21 lines
Documentation/power/swsusp.txt echo shutdown > /sys/power/disk; echo di · line 38
Quoted 6 lines
Documentation/power/swsusp.txt +6
-0+Encrypted suspend image: +------------------------ +If you want to store your suspend image encrypted with a temporary +key to prevent data gathering after resume you must compile +crypto and the aes algorithm into the kernel - modules won't work +as they cannot be loaded at resume time.Why not just `select' the needed symbols in
Kconfig? It makes configuration much easier for the user.kernel/power/swsusp.c static struct swsusp_info swsusp_info; · line 173
Quoted 3 lines
kernel/power/swsusp.c +3
-0+if (!*tfm) { +if (sizeof (key) <crypto_tfm_alg_min_keysize (*tfm)) { +if (mode) {Coding style nit: please use a single space after `if'.
kernel/power/swsusp.c static struct swsusp_info swsusp_info; · line 201
Quoted 2 lines
kernel/power/swsusp.c +2
-0+fail:crypto_free_tfm (*tfm); +out:return error;We conventionally insert a newline directly after labels.
Quoted 11 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPT +#ifdef CONFIG_SWSUSP_ENCRYPTerr, no. Please find a way to reduce the ifdeffery.
Andreas, these are yours.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Quoted 11 lines · Pavel Machek
Hi!
Quoted 8 lines
Quoted 5 lines
To prevent data gathering from swap after resume you can encrypt the suspend image with a temporary key that is deleted on resume. Note that the temporary key is stored unencrypted on disk while the system is suspended... still it means that saved data are wiped from disk during resume by simply overwritting the key.
hm, how useful is that? swap can still contain sensitive userspace stuff.
Quoted 6 lines
At least userspace has chance to mark *really* sensitive stuff as unswappable. Unfortunately that does not work against swsusp :-(.
[BTW... I was thinking about just generating random key on swapon, and using it, so that data in swap is garbage after reboot; no userspace changes needed. What do you think?]
I (and many others) are doing it already in userspace. Don't you know about dm-crypt? I think the idea is described in its docs or wiki...
I also think that doing this in swapon is risky. Because nobody will guarantee you that random seed was restored before swapon and basing this random key only on boot time and (rather deterministic) irqs at boot is risky IMHO.
In userspace, init scripts should make sure that random seed is restored before using /dev/random for anything.
Grzegorz Kulewski
Hi!
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines
To prevent data gathering from swap after resume you can encrypt the suspend image with a temporary key that is deleted on resume. Note that the temporary key is stored unencrypted on disk while the system is suspended... still it means that saved data are wiped from disk during resume by simply overwritting the key.
hm, how useful is that? swap can still contain sensitive userspace stuff.
At least userspace has chance to mark *really* sensitive stuff as unswappable. Unfortunately that does not work against swsusp :-(.
Quoted 6 lines
Quoted 3 lines
[BTW... I was thinking about just generating random key on swapon, and using it, so that data in swap is garbage after reboot; no userspace changes needed. What do you think?]
I (and many others) are doing it already in userspace. Don't you know about dm-crypt? I think the idea is described in its docs or wiki...
I could not find anything in device-mapper/*; do you have pointer to docs or wiki?
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Quoted 1 line · Pavel Machek
Hi!
Hi!
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 8 lines
Quoted 5 lines
To prevent data gathering from swap after resume you can encrypt the suspend image with a temporary key that is deleted on resume. Note that the temporary key is stored unencrypted on disk while the system is suspended... still it means that saved data are wiped from disk during resume by simply overwritting the key.
hm, how useful is that? swap can still contain sensitive userspace stuff.
At least userspace has chance to mark *really* sensitive stuff as unswappable. Unfortunately that does not work against swsusp :-(.
[BTW... I was thinking about just generating random key on swapon, and using it, so that data in swap is garbage after reboot; no userspace changes needed. What do you think?]
Quoted 5 lines
Quoted 2 lines
I (and many others) are doing it already in userspace. Don't you know about dm-crypt? I think the idea is described in its docs or wiki...
I could not find anything in device-mapper/*; do you have pointer to docs or wiki?
Just type dm-crypt in google and the first match is http://www.saout.de/misc/dm-crypt/ (the second is its wiki). Then grep that page for 'swap' and you are done. :-)
Grzegorz Kulewski
Quoted 8 lines · Andrew Morton
Quoted 5 lines · Pavel Machek
To prevent data gathering from swap after resume you can encrypt the suspend image with a temporary key that is deleted on resume. Note that the temporary key is stored unencrypted on disk while the system is suspended... still it means that saved data are wiped from disk during resume by simply overwritting the key.
[snip]
Quoted 1 line
err, no. Please find a way to reduce the ifdeffery.
Andrew,
the attached patches are acked by Pavel and signed off by me. They apply against 2.6.13-rc3 as well as 2.6.13-rc3-mm1 (with offsets) and are tested against both kernels. Please consider for inclusion (Pavel suggested that I could ask).
Note:
For 64 bit systems to work you need the following crypto fix for both kernels stated above:
http://marc.theaimsgroup.com/?l=linux-kernel&m=112160294820624&w=2
Signature · 1 line
Andreas Steinmetz SPAMmers use [email protected]
kernel/power/Kconfig +12 -0
@@ -72,6 +72,18 @@ suspended image to. It will simply pick the first available swap device. +config SWSUSP_ENCRYPT + bool "Encrypt suspend image" + depends on SOFTWARE_SUSPEND && CRYPTO=y && (CRYPTO_AES=y || CRYPTO_AES_586=y || CRYPTO_AES_X86_64=y) + default "" + ---help--- + To prevent data gathering from swap after resume you can encrypt + the suspend image with a temporary key that is deleted on + resume. + + Note that the temporary key is stored unencrypted on disk while the + system is suspended. + config SUSPEND_SMP bool depends on HOTPLUG_CPU && X86 && PM
kernel/power/swsusp.c +159 -5
247 lines not on this page · raw message
Quoted 2 lines · Andreas Steinmetz
the attached patches are acked by Pavel and signed off by me
OK, well I queued this up, without a changelog. Because you didn't send one. Please do so. As it adds a new feature, quite a bit of info is relevant.
It should include a description of what the patch tries to do, and how it does it. It should include a description of any known shortcomings. If any user configuration is needed then that should be placed somewhere under Documentation/
Take a look at how other people document their feature additions and you'll get the idea.
Please don't send multiple patches per email. In this case I did the handwork and put both diffs into the same patch.
Personally, I don't like this:
+config SWSUSP_ENCRYPT
+ bool "Encrypt suspend image"
+ depends on SOFTWARE_SUSPEND && CRYPTO=y && (CRYPTO_AES=y || CRYPTO_AES_586=y || CRYPTO_AES_X86_64=y)
This requires the user to hunt around in config until all the right options are enabled to permit SWSUSP_ENCRYPT to appear in config. That can be quite frustrating and is very poor UI.
For a top-level feature such as this it is much better to always offer the feature to the user and to then use `select' to turn on all the infrastructure bits which the user will need. Make the computer do the work rather than the user.
Yes, it might be a bit tricky in this case because you have a dependency on one of the AES encryption types, but it would be good if you can come up with something which doesn't force the user into a game of hide-and-seek.
Quoted 7 lines · Andrew Morton
Quoted 2 lines · Andreas Steinmetz
the attached patches are acked by Pavel and signed off by me
OK, well I queued this up, without a changelog. Because you didn't send one. Please do so. As it adds a new feature, quite a bit of info is relevant.
I don't like this patch. It reinvents a fair amount of dm_crypt and cryptoloop but badly.
Further, the model of security it's using is silly. In case anyone hasn't noticed, it stores the password on disk in the clear. This is so it can erase it after resume and thereby make recovery of the suspend image hard.
But laptops get stolen while they're suspended, not while they're up and running. And if your box is up and running and an attacker gains access, the contents of your suspend partition are the least of your worries. It makes no sense to expend any effort defending against this case, especially as it's liable to become a barrier to doing this right, namely with real dm_crypt encrypted swap.
At the very least, this should be renamed SWSUSP_QUICK_WIPE and any mention of encryption should be taken out of the description so users don't mistakenly think it provides any sort of useful protection.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Hi!
Quoted 14 lines
Quoted 5 lines
Quoted 1 line
the attached patches are acked by Pavel and signed off by me
OK, well I queued this up, without a changelog. Because you didn't send one. Please do so. As it adds a new feature, quite a bit of info is relevant.
I don't like this patch. It reinvents a fair amount of
dm_cryptand cryptoloop but badly.Further, the model of security it's using is silly. In case anyone hasn't noticed, it stores the password on disk in the clear. This is so it can erase it after resume and thereby make recovery of the suspend image hard.
Quoted 6 lines
But laptops get stolen while they're suspended, not while they're up and running. And if your box is up and running and an attacker gains access, the contents of your suspend partition are the least of your worries. It makes no sense to expend any effort defending against this case, especially as it's liable to become a barrier to doing this right, namely with real
dm_cryptencrypted swap.
Well, "how long are my keys going to stay in swap after swsusp"... that's pretty scary.
To prevent "stolen while suspended" case... you'd either need to enter password both during suspend and during resume, or you'd need asymetric crypto... Rather heavy.
Quoted 3 lines
At the very least, this should be renamed
SWSUSP_QUICK_WIPEand any mention of encryption should be taken out of the description so users don't mistakenly think it provides any sort of useful protection.
SWSUSP_WIPE seems like a better name, right.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Quoted 23 lines · Pavel Machek
Hi!
Quoted 14 lines
Quoted 5 lines
Quoted 1 line
the attached patches are acked by Pavel and signed off by me
OK, well I queued this up, without a changelog. Because you didn't send one. Please do so. As it adds a new feature, quite a bit of info is relevant.
I don't like this patch. It reinvents a fair amount of
dm_cryptand cryptoloop but badly.Further, the model of security it's using is silly. In case anyone hasn't noticed, it stores the password on disk in the clear. This is so it can erase it after resume and thereby make recovery of the suspend image hard.
Quoted 6 lines
But laptops get stolen while they're suspended, not while they're up and running. And if your box is up and running and an attacker gains access, the contents of your suspend partition are the least of your worries. It makes no sense to expend any effort defending against this case, especially as it's liable to become a barrier to doing this right, namely with real
dm_cryptencrypted swap.
Quoted 2 lines
Well, "how long are my keys going to stay in swap after swsusp"... that's pretty scary.
Either they're likely in RAM _anyway_ and are thus already trivially accessible to the attacker (for things like dm_crypt or IPSEC or ssh-agent), or the application took care to zero them out, or the application has a security bug.
There are about 4 attack cases, in order of likelihood:
1) An attacker steals your suspended laptop. He has access to all your suspended data. This patch gets us exactly nothing.
2) An attacker breaks into your machine remotely while you're using it. He has access to all your RAM, which if you're actually using it, very likely including the same IPSEC, dm_crypt, and ssh-agent keys as are saved on suspend. Further, he can trivially capture your keystrokes and thus capture any keys you use from that point forward. This patch gets us very close to nothing.
3) An attacker steals your unsuspended laptop. He has access to all your RAM, which in all likelihood includes your IPSEC, dm_crypt, and ssh-agent keys. Odds are good that he invokes swsusp by closing the laptop. This patch gets us very close to nothing.
4) You suspend your laptop between typing your GPG key password and hitting enter, thus leaving your password in memory when it would otherwise be cleared. Then you resume your laptop and hit enter, thus clearing the password from RAM but leaving it on the suspend partition. Then an attacker steals your machine (without re-suspending it!) and manages to recover the swsusp image which contains the password. But with this patch, he's foiled because the password is encrypted and the key's been erased! He's got all your other data though, including all the aforementioned long-lived keys.
The right fix for case 1 is dm_crypt with a password prompt. The right fix for 2 is beyond the scope of this email, but probably begins with the letters s and e. The fix for 1 goes a long way towards fixing 3 as well, provided the attacker suspends your machine. And I claim that anyone who is paranoid enough to actually care about corner cases like 4 should damn well care about case 1 too, and should be more than willing to type a password on resume, otherwise they're just fooling themselves.
Together with the fact that this reimplements dm_crypt functionality with an unreviewed and cryptographically naive replacement, I don't think this patch makes any sense at all.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Hi!
Quoted 8 lines
Quoted 2 lines
Well, "how long are my keys going to stay in swap after swsusp"... that's pretty scary.
Either they're likely in RAM _anyway_ and are thus already trivially accessible to the attacker (for things like
dm_cryptor IPSEC or ssh-agent), or the application took care to zero them out, or the application has a security bug.
Quoted 4 lines
There are about 4 attack cases, in order of likelihood:
1) An attacker steals your suspended laptop. He has access to all your suspended data. This patch gets us exactly nothing.
Wrong. Without this Andreas' patch, he'll get access to your half-a-year-old GPG passphrases, too.
Quoted 12 lines
2) An attacker breaks into your machine remotely while you're using it. He has access to all your RAM, which if you're actually using it, very likely including the same IPSEC,
dm_crypt, and ssh-agent keys as are saved on suspend. Further, he can trivially capture your keystrokes and thus capture any keys you use from that point forward. This patch gets us very close to nothing.3) An attacker steals your unsuspended laptop. He has access to all your RAM, which in all likelihood includes your IPSEC,
dm_crypt, and ssh-agent keys. Odds are good that he invokes swsusp by closing the laptop. This patch gets us very close to nothing.
Quoted 6 lines
4) You suspend your laptop between typing your GPG key password and hitting enter, thus leaving your password in memory when it would otherwise be cleared. Then you resume your laptop and hit enter, thus clearing the password from RAM but leaving it on the suspend partition. Then an attacker steals your machine (without re-suspending it!) and manages to recover the swsusp image which contains the
Why without resuspending it? Position of critical data in swap is pretty much random.
What I'm worried is: attacker steals your laptop after you were using swsusp for half a year. Now your swap partition contains random pieces of GPG keys you were using for last half a year. That's bad.
Current GPG keys can be found in RAM; unfortunately your swap partition can contain current and old GPG keys that were never supposed to be on disk. That's bad and I think we can agree on that. Andreas's patch solves it; if it was not supposed to go on disk, it will be erased after you resume. You can not do much better.
It is equivalent of clearing swsusp data from swap after resume, just implemented somewhat clever...
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Quoted 10 lines · Pavel Machek
Hi!
Quoted 8 lines
Quoted 2 lines
Well, "how long are my keys going to stay in swap after swsusp"... that's pretty scary.
Either they're likely in RAM _anyway_ and are thus already trivially accessible to the attacker (for things like
dm_cryptor IPSEC or ssh-agent), or the application took care to zero them out, or the application has a security bug.
Quoted 7 lines
Quoted 4 lines
There are about 4 attack cases, in order of likelihood:
1) An attacker steals your suspended laptop. He has access to all your suspended data. This patch gets us exactly nothing.
Wrong. Without this Andreas' patch, he'll get access to your half-a-year-old GPG passphrases, too.
Ok, I'll revise that to "very close to nothing". See below.
Quoted 19 lines
Quoted 12 lines
2) An attacker breaks into your machine remotely while you're using it. He has access to all your RAM, which if you're actually using it, very likely including the same IPSEC,
dm_crypt, and ssh-agent keys as are saved on suspend. Further, he can trivially capture your keystrokes and thus capture any keys you use from that point forward. This patch gets us very close to nothing.3) An attacker steals your unsuspended laptop. He has access to all your RAM, which in all likelihood includes your IPSEC,
dm_crypt, and ssh-agent keys. Odds are good that he invokes swsusp by closing the laptop. This patch gets us very close to nothing.Quoted 6 lines
4) You suspend your laptop between typing your GPG key password and hitting enter, thus leaving your password in memory when it would otherwise be cleared. Then you resume your laptop and hit enter, thus clearing the password from RAM but leaving it on the suspend partition. Then an attacker steals your machine (without re-suspending it!) and manages to recover the swsusp image which contains the
Quoted 2 lines
Why without resuspending it? Position of critical data in swap is pretty much random.
Typical swap partition sizes are about the same as RAM sizes. So the odds of any given thing in a previous suspend getting overwritten by the next one are high.
Quoted 3 lines
What I'm worried is: attacker steals your laptop after you were using swsusp for half a year. Now your swap partition contains random pieces of GPG keys you were using for last half a year. That's bad.
And it's incredibly unlikely. Suspending while a supposedly short-lived key is in RAM should be rare. Surviving on disk after half a year of swapping and suspending should be negligible probability.
It's not worth even thinking about when we have real suspended laptops getting stolen every day in REAL LIFE. Anyone who cares about your highly contrived case also cares about 1000 times more about the real life case of the stolen laptop. Otherwise they're fooling themselves.
This code is bad. It attacks a very rare problem, gives its users (and apparently its authors) a false sense of security, reimplements dm_crypt functionality apparently without much attention to the subtleties of block device encryption and without serious review, and it stands in the way of doing things right.
If we're going to encrypt the suspend image, let's do it right. Let's cover the real life cases and reuse code that's intended for this purpose.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Hi!
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
2) An attacker breaks into your machine remotely while you're using it. He has access to all your RAM, which if you're actually using it, very likely including the same IPSEC,
dm_crypt, and ssh-agent keys as are saved on suspend. Further, he can trivially capture your keystrokes and thus capture any keys you use from that point forward. This patch gets us very close to nothing.3) An attacker steals your unsuspended laptop. He has access to all your RAM, which in all likelihood includes your IPSEC,
dm_crypt, and ssh-agent keys. Odds are good that he invokes swsusp by closing the laptop. This patch gets us very close to nothing.4) You suspend your laptop between typing your GPG key password and hitting enter, thus leaving your password in memory when it would otherwise be cleared. Then you resume your laptop and hit enter, thus clearing the password from RAM but leaving it on the suspend partition. Then an attacker steals your machine (without re-suspending it!) and manages to recover the swsusp image which contains the
Quoted 6 lines
Quoted 2 lines
Why without resuspending it? Position of critical data in swap is pretty much random.
Typical swap partition sizes are about the same as RAM sizes. So the odds of any given thing in a previous suspend getting overwritten by the next one are high.
Well, if you suspend with 100MB of RAM used, then keep suspending half a year with only 50MB of RAM used, you'll have that half-year-old data in there.
Quoted 7 lines
Quoted 3 lines
What I'm worried is: attacker steals your laptop after you were using swsusp for half a year. Now your swap partition contains random pieces of GPG keys you were using for last half a year. That's bad.
And it's incredibly unlikely. Suspending while a supposedly short-lived key is in RAM should be rare. Surviving on disk after half a year of swapping and suspending should be negligible probability.
Disagreed.
Quoted 10 lines
It's not worth even thinking about when we have real suspended laptops getting stolen every day in REAL LIFE. Anyone who cares about your highly contrived case also cares about 1000 times more about the real life case of the stolen laptop. Otherwise they're fooling themselves.
This code is bad. It attacks a very rare problem, gives its users (and apparently its authors) a false sense of security, reimplements
dm_cryptfunctionality apparently without much attention to the subtleties of block device encryption and without serious review, and it stands in the way of doing things right.
Think about current code as really quick disk wiping method. Now, if you feel that we are giving false sense of security... we should not. Perhaps option should be renamed to CONFIG_SWSUSP_WIPE. Patches would certainly be accepted and I believe Andreas is going to cook some when he gets back online :-). I'd like to keep it there, because it enables us to do it properly in future. Contrary to what you think, I believe this is going to be part of a solution.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Quoted 59 lines · Pavel Machek
Hi!
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
2) An attacker breaks into your machine remotely while you're using it. He has access to all your RAM, which if you're actually using it, very likely including the same IPSEC,
dm_crypt, and ssh-agent keys as are saved on suspend. Further, he can trivially capture your keystrokes and thus capture any keys you use from that point forward. This patch gets us very close to nothing.3) An attacker steals your unsuspended laptop. He has access to all your RAM, which in all likelihood includes your IPSEC,
dm_crypt, and ssh-agent keys. Odds are good that he invokes swsusp by closing the laptop. This patch gets us very close to nothing.4) You suspend your laptop between typing your GPG key password and hitting enter, thus leaving your password in memory when it would otherwise be cleared. Then you resume your laptop and hit enter, thus clearing the password from RAM but leaving it on the suspend partition. Then an attacker steals your machine (without re-suspending it!) and manages to recover the swsusp image which contains the
Quoted 6 lines
Quoted 2 lines
Why without resuspending it? Position of critical data in swap is pretty much random.
Typical swap partition sizes are about the same as RAM sizes. So the odds of any given thing in a previous suspend getting overwritten by the next one are high.
Well, if you suspend with 100MB of RAM used, then keep suspending half a year with only 50MB of RAM used, you'll have that half-year-old data in there.
Quoted 7 lines
Quoted 3 lines
What I'm worried is: attacker steals your laptop after you were using swsusp for half a year. Now your swap partition contains random pieces of GPG keys you were using for last half a year. That's bad.
And it's incredibly unlikely. Suspending while a supposedly short-lived key is in RAM should be rare. Surviving on disk after half a year of swapping and suspending should be negligible probability.
Disagreed.
Quoted 10 lines
It's not worth even thinking about when we have real suspended laptops getting stolen every day in REAL LIFE. Anyone who cares about your highly contrived case also cares about 1000 times more about the real life case of the stolen laptop. Otherwise they're fooling themselves.
This code is bad. It attacks a very rare problem, gives its users (and apparently its authors) a false sense of security, reimplements
dm_cryptfunctionality apparently without much attention to the subtleties of block device encryption and without serious review, and it stands in the way of doing things right.
Quoted 7 lines
Think about current code as really quick disk wiping method. Now, if you feel that we are giving false sense of security... we should not. Perhaps option should be renamed to
CONFIG_SWSUSP_WIPE. Patches would certainly be accepted and I believe Andreas is going to cook some when he gets back online :-). I'd like to keep it there, because it enables us to do it properly in future. Contrary to what you think, I believe this is going to be part of a solution.
Matt,
this is really supposed to do wiping, nothing else. Maybe the reference to crypto may confuse a bit, but then crypto is the best way to wipe. The documentation I did send to Pavel some time ago for swsusp.txt does contain a big fat warning about that and starts with:
----------
Q: What is this 'Encrypt suspend image' for?
A: First of all: it is not a replacement for dm-crypt encrypted swap. It cannot protect your computer while it is suspended. Instead it does protect from leaking sensitive data after resume from suspend.
----------
I'm still dreaming of using dm-crypt for encrypted swap on the one hand and wiping on resume from suspend on the other working together which would mean:
You have an initrd that either prompts for a key or retrieves a key from an attached hardware device (pcmcia, usb, ...). The key is used for dmsetup to enable the encrypted swap partition. swsusp then resumes from the encrypted swap partition and wipes the suspend image.
Unfortunately, as of 2.6.13rc3 I don't see any chance for this to work (excerpt from init/main.c):
do_basic_setup();
if (sys_access((const char __user *) "/init", 0) == 0)
execute_command = "/init";
else
prepare_namespace();do_basic_setup calls do_initcalls and swsusp is using late_initcall(). prepare_namespace calls initrd_load and friends. So there is currently no chance to use an initrd to setup any crypto key.
This is really the missing link here.
Signature · 1 line
Andreas Steinmetz SPAMmers use [email protected]
Hi!
Quoted 14 lines
Quoted 5 lines
Quoted 1 line
the attached patches are acked by Pavel and signed off by me
OK, well I queued this up, without a changelog. Because you didn't send one. Please do so. As it adds a new feature, quite a bit of info is relevant.
I don't like this patch. It reinvents a fair amount of
dm_cryptand cryptoloop but badly.Further, the model of security it's using is silly. In case anyone hasn't noticed, it stores the password on disk in the clear. This is so it can erase it after resume and thereby make recovery of the suspend image hard.
Quoted 6 lines
But laptops get stolen while they're suspended, not while they're up and running. And if your box is up and running and an attacker gains access, the contents of your suspend partition are the least of your worries. It makes no sense to expend any effort defending against this case, especially as it's liable to become a barrier to doing this right, namely with real
dm_cryptencrypted swap.
I do not see why it should be liability. Even if you "properly" encrypt the swap, you'll want to wipe old data after resume.
If you take the random key (currently used), and encrypt with public key; then ask for private key on reboot; it should do the trick.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.