[dm-crypt] Exhaustive key reading seems to silently stop on error

Arno Wagner arno at wagner.name
Fri Dec 11 05:06:19 CET 2009

Hmm. This seems to indeed be a bug.

I gather there is no code later that distinguishes 
EOF and error and deals with the second possibility?


On Wed, Dec 09, 2009 at 11:25:53PM +0100, Nico R. wrote:
> Hello!
> Just a minute ago, I have subscribed to this list in order to let you
> know about what I have found in the cryptsetup code and which seems to
> be a bug to me.
> In lib/utils.c (line 450f. in cryptsetup-1.0.7; line 490f. in current
> SVN revision, r132, equal to r152), we see the following code:
> if(read(fd, pass + i, 1) != 1 || (newline_stop && pass[i] == '\n'))
>         break;
> If I interpret that snipped (and its surroundings) correctly, the code
> will read until EOF *or* until an error occurs.
> If my interpretation is true, that code causes a problem: imagine a
> hardware failure while reading the key the first two times (for
> luksFormat/luksOpen). The read function returns -1 and sets errno to
> EIO. cryptsetup continues with a truncated key, it seems. On a later
> attempt to read the key (for luksOpen), the hardware failure is gone,
> and the key can be read completely. cryptsetup will not be able to open
> the encrypted partition anymore.
> Please correct me if I got the code wrong?????? :-)
> Thanks
> -- 
> Nico

> _______________________________________________
> dm-crypt mailing list
> dm-crypt at saout.de
> http://www.saout.de/mailman/listinfo/dm-crypt

Arno Wagner, Dr. sc. techn., Dipl. Inform., CISSP -- Email: arno at wagner.name 
GnuPG:  ID: 1E25338F  FP: 0C30 5782 9D93 F785 E79C  0296 797F 6B50 1E25 338F
Cuddly UI's are the manifestation of wishful thinking. -- Dylan Evans

If it's in the news, don't worry about it.  The very definition of 
"news" is "something that hardly ever happens." -- Bruce Schneier 

More information about the dm-crypt mailing list