bugGNU GRUB - Bugs: bug #45562, grub-probe can't probe large...

 
 

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

bug #45562: grub-probe can't probe large logical volumes (LVM)

Submitter:  Rarylson Freitas <rarylson>
Submitted:  Thu 16 Jul 2015 02:55:21 PM UTC
   
 
Category:  Disk & Partition Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  Invalid Privacy:  Public
Assigned to:  None Originator Name:  Rarylson Freitas
Open/Closed:  Closed Release:  Git master
Release:  Reproducibility:  Every Time
Planned Release:  None

Fri 17 Jul 2015 08:16:14 PM UTC, comment #4: 

Hi Andrei,

You're right.

Only Ubuntu 12.04 still using the int/unsigned int counters.

I haven't noticed this change (using 64 bits instead of int/unsigned int) in the upstream code.

So, only the specific Ubuntu bug report should be kept.

Sorry for any inconvenience.

Rarylson Freitas <rarylson>
Fri 17 Jul 2015 05:35:32 PM UTC, comment #3: 

extent_size and extent_count are 64 bit since 3 years. Not sure what upstream code you refer to.

Andrei Borzenkov <arvidjaar>
Group Member
Fri 17 Jul 2015 02:08:38 AM UTC, comment #2: 

Hi,

The output of the "problematic" LV is:

$ lvs -o seg_size,vg_extent_size --units s --nosuffix \

> /dev/data/mail


  SSize      Ext
  4294967296 8192

And if I do not specify the LV (output of all LVs):

$ lvs -o seg_size,vg_extent_size --units s --nosuffix
  SSize      Ext
     1949696 8192
  3221225472 8192
  2147483648 8192
  4294967296 8192
  4294967296 8192
  1050673152 8192
    52428800 8192
    52428800 8192
  2147483648 8192
   209715200 8192
    10485760 8192
    62914560 8192
    41943040 8192
    83886080 8192
    10485760 8192
    62914560 8192
  1048576000 8192
  1048576000 8192
    97648640 8192

The problem only occurs when probing our biggest LV.

Rarylson Freitas <rarylson>
Thu 16 Jul 2015 05:42:27 PM UTC, comment #1: 

Could you post output of

lvs -o seg_size,vg_extent_size --units s --nosuffix

Andrei Borzenkov <arvidjaar>
Group Member
Thu 16 Jul 2015 02:55:21 PM UTC, original submission:  

Hi,

I've had a problem when using the `grub-probe` binary to probe large LVM partitions (for example, a 1.5 TB partition).

This problem was discovered/tested in an Ubuntu 12.04.5.

When trying to probe these large LVM partitions, we get erros like:

    $ grub-probe -vvv /PATH/TO/MY/LVM
    [...]
    grub-core/kern/disk.c:494: Read out of range: sector 0x0 (out of disk).
    [...]
    grub-probe: error: unknown filesystem.

This bug was reported at: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1475337

However, as I discovered that the same problematic source code exists in the upstream too, I'm creating this bug report here too.

Talking about the bug:

I debug the problem and I discovered that the problem occurs due to an inappropriate multiplication in the file grub-core/disk/lvm.c:

    lv->size += seg->extent_count * vg->extent_size;

The lv->size var is an unsigned 64-bits integer. However, the next two vars are respectively an unsigned int and an int. As the result of (unsigned int) * (int) is an integer, it's very easy to get a multiplication overflow (in my case, the result of the multiplication was zero -> lv->size = 0, resulting in the "out of disk" error).

So, I'm proposing a patch for this bug (it was created over the current commit in Git, Master branch - commit ff3c20):

diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
index 7b265c7..4a39a5b 100644
--- a/grub-core/disk/lvm.c
+++ b/grub-core/disk/lvm.c
@@ -463,7 +463,8 @@ grub_lvm_detect (grub_disk_t disk,
      goto lvs_segment_fail;
    p += sizeof("type = \"") - 1;
 
-   lv->size += seg->extent_count * vg->extent_size;
+   lv->size += ((grub_uint64_t) seg->extent_count
+ * (grub_uint64_t) vg->extent_size);
 
    if (grub_memcmp (p, "striped\"",
     sizeof ("striped\"") - 1) == 0)


I only tested this patch in my Ubuntu server using the Debian patched code (not the upstream code). So, I don't know if it works in the upstream code too.


I'm attaching this patch too.

Rarylson Freitas <rarylson>

 

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

Attached Files
file #34453:  lvm_big_size_upstream.patch added by rarylson (490B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arvidjaar (Posted a comment)
  • -email is unavailable- added by rarylson (Submitted the item)
  • -email is unavailable- added by rarylson
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-07-17 arvidjaar StatusNone Invalid
        Open/ClosedOpen Closed
    2015-07-16 rarylson Attached File- Added lvm_big_size_upstream.patch, #34453
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code