eternaltyro / cryptsetup

Since Google code is shuttering...
http://code.google.com/p/cryptsetup
GNU General Public License v2.0
0 stars 0 forks source link

luksAddKey does not work and results in high cpu usage #192

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. cryptsetup luksAddKey <device>

What is the expected output? What do you see instead?

Finish in a reasonable amount of time after asking for the existing and the new 
key.

What version of the product are you using? On what operating system?

OS: Gentoo Linux

cryptsetup-1.6.2
dev-libs/libgcrypt: 1.5.3 or 1.6.0 does not change anything

with
USE: kernel nls -gcrypt -nettle -openssl -python -reencrypt -static 
-static-libs -udev -urandom
PYTHON_SINGLE_TARGET="python2_7 -python2_6"
PYTHON_TARGETS="python2_7 -python2_6"

Please provide any additional information below.

The gentoo installation is running in a single core hyper-v virtual machine 
hosted on windows server 2008.

After disabling the USE flag "gcrypt" and enabling the "kernel" USE flag 
cryptsetup added my key in less than 3 seconds. Before the program would run 
endlessly (I killed it after 1 hour) and max out all cores of the virtual 
machine. I have run cryptsetup with strace and attached the log.

Original issue reported on code.google.com by kbla...@gmail.com on 20 Dec 2013 at 9:46

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry the line

USE: kernel nls -gcrypt -nettle -openssl -python -reencrypt -static 
-static-libs -udev -urandom

in the first comment is a mistake. It shows the changes I have made to *fix* my 
problem.

The "bad" state occured with

USE: -kernel nls gcrypt -nettle -openssl -python -reencrypt -static 
-static-libs -udev -urandom

Notice the difference

-kernel gcrypt VS. kernel -gcrypt

Original comment by kbla...@gmail.com on 20 Dec 2013 at 9:48

GoogleCodeExporter commented 9 years ago
Please can you try 1.6.3 version? If it still doesn't work , please also add 
output of the command with added --debug. Thanks.

Anyway, USE setting is Gentoo specific, it would be probably better to report 
it directly to Gentoo bugzilla.
(But I am using it as well, so if I can reproduce it, I can try to fix it... 
But on my Gentoo installation gcrypt backend works with no problem)

Original comment by gmazyl...@gmail.com on 21 Dec 2013 at 12:17

GoogleCodeExporter commented 9 years ago
I tested 1.6.3 and it had the same problem. The attachement shows the output of 

cryptsetup luksAddKey --debug /dev/vg/crypt

Original comment by kbla...@gmail.com on 22 Dec 2013 at 2:57

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks. So the problem is that pbkdf2 benchmark uses getrsusage syscall and it 
returns always zero usage time... (it should fail in 10th iteration if thois 
happens but unfortunately this time is too long for user to wait).

getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={0, 892586}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={1, 314464}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={1, 314464}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={6, 873070}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={6, 873070}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={95, 980522}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={95, 980522}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={1526, 865445}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={1526, 865445}, ...}) = 0

I wonder how this can happen (this should happen only if cumputation is done in 
kernel - which explains why kernel backend works here.)

I can rewrite it or use some workaround (I removed getrusage from cipher 
benchmarking as well) but first we should find out why there is no CPU time at 
all for your config...

With gcrypt, you should see something like
getrusage(RUSAGE_SELF, {ru_utime={2, 300000}, ru_stime={0, 30000}, ...}) = 0
...

Original comment by gmazyl...@gmail.com on 22 Dec 2013 at 7:53

GoogleCodeExporter commented 9 years ago
This looks to me like some bug in MS hyper-v & getrusage() ...

Anyway, I tried to add some workaround
http://code.google.com/p/cryptsetup/source/detail?r=7415c5858d09f5408080a0c877b8
7038ff7a9858

Please can you try to use git version if it works? (or just apply the last 
patch to 1.6.3). Thanks.

Original comment by gmazyl...@gmail.com on 22 Dec 2013 at 9:16

GoogleCodeExporter commented 9 years ago
This fixed it for me. I have attached logs of

cryptsetup --debug luksAddKey /dev/vg/crypt

for the revisions 8e5411f468ae and 7415c5858d09.

Thanks :)

Original comment by kbla...@gmail.com on 22 Dec 2013 at 1:00

Attachments:

GoogleCodeExporter commented 9 years ago
ok, thanks. So I'll keep this workaround in place. (The KDF benchmark need some 
changes in future anyway, some notes in Issue#185)

Thanks for reporting it.

Original comment by gmazyl...@gmail.com on 23 Dec 2013 at 9:36