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 17:38:28 +0100	[thread overview]
Message-ID: <20061229163828.GA24234@deprecation.cyrius.com> (raw)
In-Reply-To: <87lkkrgej4.wl%clemens@endorphin.org>

* Clemens Fruhwirth <clemens@endorphin.org> [2006-12-29 11:52]:
> I just added the r!=bsize case to error checking and an error message
> as well.
...
> The changes are also in subversion.

This particular change didn't make any difference.  I still get the
header conversion message when I only apply the patch from utils.c.


#! /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;

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

  reply	other threads:[~2006-12-29 16:38 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 [this message]
2006-12-29 20:24     ` Martin Michlmayr
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=20061229163828.GA24234@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.