bugGNU GRUB - Bugs: bug #46164, UFS sparse file memset

 
 

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

bug #46164: UFS sparse file memset

Submitted by:  Alexander Bluhm <bluhm>
Submitted on:  Fri 09 Oct 2015 11:17:18 AM UTC  
 
Category: FilesystemSeverity: Major
Priority: 5 - NormalItem Group: Software Error
Status: FixedPrivacy: Public
Assigned to: NoneOriginator Name: 
Open/Closed: ClosedRelease: 
Release: Git masterReproducibility: Every Time
Planned Release: None

Fri 09 Oct 2015 11:17:18 AM UTC, original submission:

When creating a sparse file, that is a file with 0 not written to
disk, on an OpenBSD FFS file system, GRUB does not read it correctly.

The UFS code in GRUB is responsible for reading FFS file systems,
it can handle sparse files, but has a bug there. The second
and third parameters for memset() are exchanged.

It is defined as
void grub_memset (void s, int c, grub_size_t len)
but called as
grub_memset (buf, UFS_BLKSZ (sblock) - skipfirst, 0)

Also the length of the buffer is not checked, so the last block
could cause an overflow. The blockend variable seems to contain
the correct length already.

I have found the bug and tested the fix with OpenBSD and GRUB 2.
The git master has the same code.

Alexander Bluhm

--- a/contrib/grub2/grub-core/fs/ufs.c
+++ b/contrib/grub2/grub-core/fs/ufs.c
@@ -394,7 +394,7 @@ grub_ufs_read_file (struct grub_ufs_data *data,
return -1;
}
else
- grub_memset (buf, UFS_BLKSZ (sblock) - skipfirst, 0);
+ grub_memset (buf, 0, blockend);

buf += UFS_BLKSZ (sblock) - skipfirst;
}

Alexander Bluhm <bluhm>

 

Attached Files
file #35122:  grub.diff added by bluhm (324B - application/octet-stream - Patch ufs.c)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by phcoder (Updated the item)
  • -unavailable- added by bluhm (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 09 Oct 2015 11:55:26 AM UTCphcoderStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Fri 09 Oct 2015 11:17:18 AM UTCbluhmAttached File-=>Added grub.diff, #35122

    Back to the top


    Powered by Savane 3.1-cleanup1