linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] e2fsprogs: e2fsck_handle_read_error - pass along negative count
@ 2012-08-06 20:05 Jim Keniston
  2012-08-06 22:55 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Keniston @ 2012-08-06 20:05 UTC (permalink / raw)
  To: tytso, linux-ext4; +Cc: ddstreet, mcao, alexfr

When passed a negative count (indicating a byte count rather than
a block count) e2fsck_handle_read_error() treats the data as a full
block, causing unix_write_blk64() (which can handle negative counts
just fine) to try to write too much.  Given a faulty block device,
this resulted in a SEGV when unix_write_blk64() read past the bottom
of the stack copying the data to cache.  (check_backup_super_block ->
unix_read_blk64 -> raw_read_blk -> e2fsck_handle_read_error)

Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
Signed-off-by: Dan Streetman <ddstreet@us.ibm.com>
Reviewed-by: Mingming Cao <mcao@us.ibm.com>
Reported-by: Alex Friedman <alexfr@il.ibm.com>
---

 e2fsck/ehandler.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c
index 6eecf33..6dddf9c 100644
--- a/e2fsck/ehandler.c
+++ b/e2fsck/ehandler.c
@@ -60,7 +60,7 @@ static errcode_t e2fsck_handle_read_error(io_channel channel,
 	preenhalt(ctx);
 	if (ask(ctx, _("Ignore error"), 1)) {
 		if (ask(ctx, _("Force rewrite"), 1))
-			io_channel_write_blk64(channel, block, 1, data);
+			io_channel_write_blk64(channel, block, count, data);
 		return 0;
 	}
 


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

* Re: [PATCH] e2fsprogs: e2fsck_handle_read_error - pass along negative count
  2012-08-06 20:05 [PATCH] e2fsprogs: e2fsck_handle_read_error - pass along negative count Jim Keniston
@ 2012-08-06 22:55 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2012-08-06 22:55 UTC (permalink / raw)
  To: Jim Keniston; +Cc: linux-ext4, ddstreet, mcao, alexfr

On Mon, Aug 06, 2012 at 01:05:53PM -0700, Jim Keniston wrote:
> When passed a negative count (indicating a byte count rather than
> a block count) e2fsck_handle_read_error() treats the data as a full
> block, causing unix_write_blk64() (which can handle negative counts
> just fine) to try to write too much.  Given a faulty block device,
> this resulted in a SEGV when unix_write_blk64() read past the bottom
> of the stack copying the data to cache.  (check_backup_super_block ->
> unix_read_blk64 -> raw_read_blk -> e2fsck_handle_read_error)
> 
> Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
> Signed-off-by: Dan Streetman <ddstreet@us.ibm.com>
> Reviewed-by: Mingming Cao <mcao@us.ibm.com>
> Reported-by: Alex Friedman <alexfr@il.ibm.com>

Thanks, applied!  I changed the one-line summary to read:

e2fsck: fix potential segv when handling a read error in a superblock

	    	      	   		 - Ted

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

end of thread, other threads:[~2012-08-06 22:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-06 20:05 [PATCH] e2fsprogs: e2fsck_handle_read_error - pass along negative count Jim Keniston
2012-08-06 22:55 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).