From: Jim Keniston Date: Mon, 6 Aug 2012 22:46:03 +0000 (-0400) Subject: e2fsck: fix potential segv when handling a read error in a superblock X-Git-Tag: v1.43-WIP-2012-09-22~12^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d45b67c5f2a66597d8e2915052e180203a9193b8;p=thirdparty%2Fe2fsprogs.git e2fsck: fix potential segv when handling a read error in a superblock 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) Reported-by: Alex Friedman Signed-off-by: Jim Keniston Signed-off-by: Dan Streetman Reviewed-by: Mingming Cao Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/ehandler.c b/e2fsck/ehandler.c index 6eecf33f8..6dddf9c17 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; }