All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Michlmayr <tbm@cyrius.com>
To: Clemens Fruhwirth <clemens@endorphin.org>
Cc: 403426@bugs.debian.org, dm-devel@redhat.com,
	Brian Brunswick <bdb-reportbug@forbidden.co.uk>
Subject: Re: Bug#403426: kernel corrupts LUKS partition header on arm
Date: Fri, 29 Dec 2006 21:24:34 +0100	[thread overview]
Message-ID: <20061229202434.GD23246@deprecation.cyrius.com> (raw)
In-Reply-To: <87lkkrgej4.wl%clemens@endorphin.org>

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

* Clemens Fruhwirth <clemens@endorphin.org> [2006-12-29 11:52]:
> Please try the version from subversion
> http://luks.endorphin.org/svn/cryptsetup

With 1.0.4 plus the attached 2 patches from SVN I no longer get any
corruption but I also cannot access my encrypted data.  Is there
anything else I should try?


foobar:~# cryptsetup luksOpen /dev/sda5 x
Enter LUKS passphrase:
device-mapper: table: 254:0: crypt: Device lookup failed
device-mapper: ioctl: error adding target to table
device-mapper: ioctl: device doesn't appear to be in the dev hash table.
Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda5 contains at least 133 sectors.
Failed to read from key storage
Enter LUKS passphrase:
device-mapper: table: 254:0: crypt: Device lookup failed
device-mapper: ioctl: error adding target to table
device-mapper: ioctl: device doesn't appear to be in the dev hash table.
Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda5 contains at least 133 sectors.
Failed to read from key storage
Enter LUKS passphrase:
device-mapper: table: 254:0: crypt: Device lookup failed
device-mapper: ioctl: error adding target to table
device-mapper: ioctl: device doesn't appear to be in the dev hash table.
Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda5 contains at least 133 sectors.
Failed to read from key storage
Command failed: No key available with this passphrase.

foobar:~# cryptsetup luksOpen /dev/sda5 x
Enter LUKS passphrase:
device-mapper: table: 254:0: crypt: Device lookup failed
device-mapper: ioctl: error adding target to table
device-mapper: ioctl: device doesn't appear to be in the dev hash table.
Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda5 contains at least 133 sectors.
Failed to read from key storage
Enter LUKS passphrase:
device-mapper: table: 254:0: crypt: Device lookup failed
device-mapper: ioctl: error adding target to table
device-mapper: ioctl: device doesn't appear to be in the dev hash table.
Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda5 contains at least 133 sectors.
Failed to read from key storage
Enter LUKS passphrase:
device-mapper: table: 254:0: crypt: Device lookup failed
device-mapper: ioctl: error adding target to table
device-mapper: ioctl: device doesn't appear to be in the dev hash table.
Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda5 contains at least 133 sectors.
Failed to read from key storage
Command failed: No key available with this passphrase.

foobar:~#

-- 
Martin Michlmayr
http://www.cyrius.com/

[-- Attachment #2: 02_fix_arm.dpatch --]
[-- Type: text/plain, Size: 1725 bytes --]

#! /bin/sh /usr/share/dpatch/dpatch-run
## 02_fix_arm.dpatch by Clemens Fruhwirth <clemens@endorphin.org>
##
## DP: Add error checking to read_blockwise for short reads.
## DP: Commit a patch that fixes http://bugs.debian.org/403075

@DPATCH@
Index: lib/utils.c
===================================================================
--- cryptsetup-1.0.4~/lib/utils.c	(revision 1)
+++ cryptsetup-1.0.4/lib/utils.c	(working copy)
@@ -151,8 +151,10 @@
 static int sector_size(int fd) 
 {
 	int bsize;
-	ioctl(fd,BLKSSZGET, &bsize);
-	return bsize;
+	if (ioctl(fd,BLKSSZGET, &bsize) < 0)
+		return -EINVAL;
+	else
+		return bsize;
 }
 
 int sector_size_for_device(const char *device)
@@ -171,8 +173,11 @@
 	char *padbuf; char *padbuf_base;
 	char *buf = (char *)orig_buf;
 	int r;
-	int hangover; int solid; int bsize = sector_size(fd);
+	int hangover; int solid; int bsize;
 
+	if ((bsize = sector_size(fd)) < 0)
+		return bsize;
+
 	hangover = count % bsize;
 	solid = count - hangover;
 
@@ -209,15 +214,20 @@
 	char *buf = (char *)orig_buf;
 	int r;
 	int step;
-	int bsize = sector_size(fd);
+	int bsize;
 
+	if ((bsize = sector_size(fd)) < 0)
+		return bsize;
+
 	padbuf = aligned_malloc(&padbuf_base, bsize, bsize);
 	if(padbuf == NULL) return -ENOMEM;
 
 	while(count) {
 		r = read(fd,padbuf,bsize);
-		if(r < 0) goto out;
-		
+		if(r < 0 || r != bsize) {
+			fprintf(stderr, "read failed in read_blockwise.\n");
+			goto out;
+		}
 		step = count<bsize?count:bsize;
 		memcpy(buf,padbuf,step);
 		buf += step;
@@ -242,6 +252,9 @@
 	int frontHang = offset % bsize;
 	int r;
 
+	if (bsize < 0)
+		return bsize;
+
 	lseek(fd, offset - frontHang, SEEK_SET);
 	if(offset % bsize) {
 		int innerCount = count<bsize?count:bsize;

[-- Attachment #3: 03_no_header_conv.dpatch --]
[-- Type: text/plain, Size: 1398 bytes --]

#! /bin/sh /usr/share/dpatch/dpatch-run
## 03_no_header_conv.patch by Clemens Fruhwirth <clemens@endorphin.org>
##
## DP: Kick ancient version header conversion.

@DPATCH@
Index: luks/keymanage.c
===================================================================
--- a/luks/keymanage.c	(revision 19)
+++ b/luks/keymanage.c	(working copy)
@@ -67,14 +67,6 @@
 	return mk;
 }
 
-static inline void convert_V99toV991(char const *device, struct luks_phdr *hdr) {
-	struct luks_phdr tmp_phdr;
-	fputs(_("automatic header conversion from 0.99 to 0.991 triggered"), stderr);
-	hdr->mkDigestIterations = ntohs(htonl(hdr->mkDigestIterations));
-	memcpy(&tmp_phdr, hdr, sizeof(struct luks_phdr));
-	LUKS_write_phdr(device, &tmp_phdr); 
-}
-
 int LUKS_read_phdr(const char *device, struct luks_phdr *hdr)
 {
 	int devfd = 0; 
@@ -109,14 +101,6 @@
 			hdr->keyblock[i].passwordIterations = ntohl(hdr->keyblock[i].passwordIterations);
 			hdr->keyblock[i].keyMaterialOffset  = ntohl(hdr->keyblock[i].keyMaterialOffset);
 			hdr->keyblock[i].stripes            = ntohl(hdr->keyblock[i].stripes);
-
-			if(hdr->keyblock[i].active == LUKS_KEY_DISABLED_OLD) {
-				hdr->keyblock[i].active = LUKS_KEY_DISABLED;
-				convert_V99toV991(device, hdr);
-			} else if(hdr->keyblock[i].active == LUKS_KEY_ENABLED_OLD) {
-				hdr->keyblock[i].active = LUKS_KEY_ENABLED;
-				convert_V99toV991(device, hdr);
-			}
 		}
 	}
 

[-- Attachment #4: Type: text/plain, Size: 0 bytes --]



  parent reply	other threads:[~2006-12-29 20:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20061217022906.2434.60658.reportbug@LKG8A754B.example.org>
2006-12-20 16:15 ` Bug#403426: kernel corrupts LUKS partition header on arm Martin Michlmayr
2006-12-29 10:52   ` Clemens Fruhwirth
2006-12-29 16:38     ` Martin Michlmayr
2006-12-29 20:24     ` Martin Michlmayr [this message]
2006-12-30 10:50       ` Clemens Fruhwirth
2006-12-30 13:13         ` Martin Michlmayr
2007-01-02 17:00           ` Clemens Fruhwirth
2007-01-02 18:04             ` Martin Michlmayr
2007-01-02 18:34               ` Clemens Fruhwirth
2007-01-03 16:59               ` Clemens Fruhwirth
2007-01-03 19:14                 ` Martin Michlmayr
2007-01-03 19:32                   ` Clemens Fruhwirth
2007-01-03 19:37                     ` Martin Michlmayr
2007-01-04 11:56                       ` Clemens Fruhwirth
2007-01-04 15:09                         ` Martin Michlmayr
2007-01-05  8:36                           ` Gordon Farquharson
2007-01-05  9:59                             ` Martin Michlmayr
2007-01-06  6:38                               ` Gordon Farquharson
2007-01-07  5:47                             ` Gordon Farquharson

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=20061229202434.GD23246@deprecation.cyrius.com \
    --to=tbm@cyrius.com \
    --cc=403426@bugs.debian.org \
    --cc=bdb-reportbug@forbidden.co.uk \
    --cc=clemens@endorphin.org \
    --cc=dm-devel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.