DM-Crypt Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [dm-crypt] Exhaustive key reading seems to silently stop on error
@ 2009-12-09 22:25 Nico R.
  2009-12-11  4:06 ` Arno Wagner
  0 siblings, 1 reply; 4+ messages in thread
From: Nico R. @ 2009-12-09 22:25 UTC (permalink / raw)
  To: dm-crypt

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dm-crypt] Exhaustive key reading seems to silently stop on error
  2009-12-09 22:25 [dm-crypt] Exhaustive key reading seems to silently stop on error Nico R.
@ 2009-12-11  4:06 ` Arno Wagner
  2009-12-11 10:57   ` Nico R.
  0 siblings, 1 reply; 4+ messages in thread
From: Arno Wagner @ 2009-12-11  4:06 UTC (permalink / raw)
  To: dm-crypt

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?

Arno


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@saout.de
> http://www.saout.de/mailman/listinfo/dm-crypt


-- 
Arno Wagner, Dr. sc. techn., Dipl. Inform., CISSP -- Email: arno@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 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dm-crypt] Exhaustive key reading seems to silently stop on error
  2009-12-11  4:06 ` Arno Wagner
@ 2009-12-11 10:57   ` Nico R.
  2009-12-11 11:59     ` Milan Broz
  0 siblings, 1 reply; 4+ messages in thread
From: Nico R. @ 2009-12-11 10:57 UTC (permalink / raw)
  To: dm-crypt

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

Hi!

(De-TOFU-ized.)

> On Wed, Dec 09, 2009 at 11:25:53PM +0100, Nico R. wrote:
[…]
>> 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:
[…]

Arno Wagner wrote:
> 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?

As far as I can see, there is not. See
<URL:http://code.google.com/p/cryptsetup/source/browse/trunk/lib/utils.c?r=132#480>.
-- 
Nico


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dm-crypt] Exhaustive key reading seems to silently stop on error
  2009-12-11 10:57   ` Nico R.
@ 2009-12-11 11:59     ` Milan Broz
  0 siblings, 0 replies; 4+ messages in thread
From: Milan Broz @ 2009-12-11 11:59 UTC (permalink / raw)
  To: Nico R.; +Cc: dm-crypt

On 12/11/2009 11:57 AM, Nico R. wrote:

>>> 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.

yes, sure it is bug, thanks for reporting it.

Fixed in trunk now
http://code.google.com/p/cryptsetup/source/detail?r=154#

Milan
--
mbroz@redhat.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-11 11:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-09 22:25 [dm-crypt] Exhaustive key reading seems to silently stop on error Nico R.
2009-12-11  4:06 ` Arno Wagner
2009-12-11 10:57   ` Nico R.
2009-12-11 11:59     ` Milan Broz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox