e2fsprogs: e2fsck_handle_read_error - pass along negative count
PATCH 1/1 e2fsprogs: e2fsck_handle_read_error - pass along negative count
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)
---
e2fsck/ehandler.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
e2fsck/ehandler.c +1 -1
@@ -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 ; }
Theodore Ts'o
AppliedQuoted 8 lines · Jim Keniston
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, causingunix_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 whenunix_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)
Quoted 4 lines
Signed-off-by Jim Keniston <[email protected]>Signed-off-by Dan Streetman <[email protected]>Reviewed-by Mingming Cao <[email protected]>Reported-by Alex Friedman <[email protected]>
Thanks, applied! I changed the one-line summary to read:
e2fsck: fix potential segv when handling a read error in a superblock
- Ted