bugGNU GRUB - Bugs: bug #43443, GRUB fails to handle 'absent'...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #43443: GRUB fails to handle 'absent' (zero) indirect block inode table entries on ext2 volumes

Submitter:  Peter Nelson <peterdn>
Submitted:  Sun 19 Oct 2014 11:59:48 PM UTC
   
 
Category:  Filesystem Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  Fixed Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Closed Release:  Git master
Release:  Reproducibility:  Every Time
Planned Release:  None

Sun 19 Oct 2014 11:59:48 PM UTC, original submission:  

Linux (or at least Ubuntu 14.04) appears to set an indirect block ID (in an ext2 file's inode table) to 0 to indicate that all child blocks are zero-filled if there's a large gap in that file. If GRUB is asked to read such a file via a {multiboot|module|cat|testload|...} command, it fails with "error: attempt to read or write outside of disk `hd0'". This is because GRUB attempts to follow the the `0' entry and ends up reading garbage in the block it thinks is the sub-table.




Steps to reproduce:

1) Create and/or otherwise mount a disposable ext2 formatted disk(-image):

dd if=/dev/zero of=test.img bs=512 count=131072
mkfs.ext2 -F test.img
sudo losetup /dev/loop0 test.img
sudo mount -t ext2 /dev/loop0 /media/usb


2) Install GRUB on the disk

sudo grub-install --root-directory=/media/usb --no-floppy --force /dev/loop0


3) Create a file with a large zero-filled gap (just enough to ensure every block under the entire first-indirect entry is zero-filled):

dd if=/dev/zero of=/media/usb/test bs=512 seek=1025 count=1


4) Verify that the only blocks associated with this inode are the root doubly-indirect block, its child single-indirect block and grandchild direct block:

debugfs -R "stat test" test.img
> BLOCKS:
> (DIND):530, (IND):531, (512):11777


5) Boot from test.img in bochs or otherwise; at GRUB command prompt try to load the file:

testload /test
> error: attempt to read or write outside of disk `hd0'.





I've attached a patch that simply checks whether a block ID is 0 before attempting to follow the indirection chain. It appears to fix this issue in my case.

Peter Nelson <peterdn>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #32302:  ext2_absent_block.patch added by peterdn (521B - application/octet-stream - Patch for issue)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by phcoder (Updated the item)
  • -email is unavailable- added by peterdn (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-12-07 phcoder StatusNone Fixed
        Open/ClosedOpen Closed
    2014-10-19 peterdn Attached File- Added ext2_absent_block.patch, #32302

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code