bugGNU GRUB - Bugs: bug #44199, grub2-mkconfig:...

 
 

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

bug #44199: grub2-mkconfig: /usr/share/grub/grub-mkconfig_lib: line 56: 26488 Segmentation fault "${grub_probe}" -t fs "$path"

Submitter:  Ilya Tumaykin <coacher>
Submitted:  Sat 07 Feb 2015 01:37:27 AM UTC
   
 
Category:  None Severity:  Major
Priority:  5 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Closed Release:  Git master
Release:  Reproducibility:  None
Planned Release:  None

Jump to the original submission

Sat 14 Feb 2015 09:56:44 PM UTC, comment #12: 

Yes, it is fixed now with latest vanilla git ( 2ae9457e6eb4c352051fb32bc6fc931a22528ab2). Thanks!

Ilya Tumaykin <coacher>
Sat 14 Feb 2015 02:58:33 PM UTC, comment #11: 

Fixed (slightly differently) in e27fdbd6866a3dc9c6ee4d777d89c861f04368e7. Please reopen if you still see problem.

Andrei Borzenkov <arvidjaar>
Group Member
Fri 13 Feb 2015 08:00:04 PM UTC, comment #10: 

Could you test attached patch?

(file #33067)

Andrei Borzenkov <arvidjaar>
Group Member
Fri 13 Feb 2015 07:22:15 PM UTC, comment #9: 

Please build with debugging enabled to get parameters and also show "list" output so exact source line can be identified. But my guess is it is

+  if (lv->vg->extent_size == 0)

which is the only place where it does not check before dereference. Not sure if having no vg at this point is valid.

Andrei Borzenkov <arvidjaar>
Group Member
Thu 12 Feb 2015 07:52:43 PM UTC, comment #8: 

Plasma ~ # grub2-probe -t fs /usr/share/grub/unicode.pf2
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Segmentation fault (core dumped)
Plasma ~ # gdb /usr/sbin/grub2-probe core
GNU gdb (Gentoo 7.8.1 vanilla) 7.8.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/grub2-probe...(no debugging symbols found)...done.
[New LWP 22362]

warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `grub2-probe -t fs /usr/share/grub/unicode.pf2'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000046f544 in validate_lv ()
(gdb) bt
#0  0x000000000046f544 in validate_lv ()
#1  0x00000000004706b9 in grub_diskfilter_vg_register ()
#2  0x0000000000470c08 in grub_diskfilter_make_raid ()
#3  0x0000000000406f61 in grub_mdraid_detect ()
#4  0x000000000046f1ae in scan_disk_partition_iter ()
#5  0x0000000000467b11 in part_iterate ()
#6  0x0000000000470fa0 in grub_gpt_partition_map_iterate ()
#7  0x0000000000467826 in grub_partition_iterate ()
#8  0x000000000046f76e in scan_disk ()
#9  0x0000000000470c3b in grub_diskfilter_get_pv_from_disk ()
#10 0x000000000046eaab in grub_util_get_ldm ()
#11 0x000000000045f151 in grub_util_biosdisk_get_grub_dev ()
#12 0x000000000045f3b6 in grub_util_pull_device ()
#13 0x0000000000461465 in grub_util_pull_device_os ()
#14 0x000000000045f3aa in grub_util_pull_device ()
#15 0x000000000045ff28 in grub_util_pull_lvm_by_command ()
#16 0x000000000045f3c8 in grub_util_pull_device ()
#17 0x0000000000403685 in probe ()
#18 0x0000000000402f05 in main ()

Ilya Tumaykin <coacher>
Thu 12 Feb 2015 11:03:28 AM UTC, comment #7: 

ext4 vs ext2: GRUB doesn't distinguish them.
Can you paste the backtrace? I can't extract it out of the core dump without the binary.

Vladimir Serbinenko <phcoder>
Group administrator
Thu 12 Feb 2015 12:42:14 AM UTC, comment #6: 

BTW, when grub-probe was not segfaulting during the bisect run I've noticed it detects filesystem as ext2, but in reality it is ext4. ext4 on LVM over mdraid. Maybe such a complex setup makes grub-probe detect filesystem incorrectly.

Ilya Tumaykin <coacher>
Wed 11 Feb 2015 11:18:08 PM UTC, comment #5: 

Sorry, I've messed up during my previous bisecting session. Here's the proper one:
git bisect start
# good: [06eadf5ebf21c8520d696c6438a976e5f7c218c3] fix double free in grub_net_recv_tcp_packet
git bisect good 06eadf5ebf21c8520d696c6438a976e5f7c218c3
# bad: [c0f529ea679bdf48cbe1c4b3dd92fb552456a1fe] arm: implement additional relocations generated by gcc 4.9 at -O3
git bisect bad c0f529ea679bdf48cbe1c4b3dd92fb552456a1fe
# bad: [b6f21bcb98f03d61087b4423261bda5d6a58fb1f] fs/cbfs: Add missing free.
git bisect bad b6f21bcb98f03d61087b4423261bda5d6a58fb1f
# bad: [44b38e49885ffcb286e796b572f3f862f3be371a] grub_menu_init_page: Avoid returning 0 geometry to avoid divisions by 0.
git bisect bad 44b38e49885ffcb286e796b572f3f862f3be371a
# good: [935863518f3a9ec12161616a31ac40e5b78bd550] grub_dmraid_nv_detect: Do not divide by zero.
git bisect good 935863518f3a9ec12161616a31ac40e5b78bd550
# bad: [4816dcac19a05a1209822015d88903faef3d6f44]       * grub-core/video/readers/jpeg.c: Avoid division by zero.
git bisect bad 4816dcac19a05a1209822015d88903faef3d6f44
# good: [065ed900d4865fc31062f01290560ad1bc189522] grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0.
git bisect good 065ed900d4865fc31062f01290560ad1bc189522
# good: [475bffeae67fa0f6787c33147c120b40e89b1985]      * grub-core/fs/zfs.c: Avoid divisions by zero.
git bisect good 475bffeae67fa0f6787c33147c120b40e89b1985
# bad: [750f4bacd3262376ced3f837d8dc78f834ca233a] * grub-core/disk/diskfilter.c: Validate volumes to avoid division by zero.
git bisect bad 750f4bacd3262376ced3f837d8dc78f834ca233a
# good: [1b6aaddc456961d87d98e0f342c70b874b2fb232] term.h: Avoid returining 0-sized terminal as it may lead to division by zero.
git bisect good 1b6aaddc456961d87d98e0f342c70b874b2fb232
# first bad commit: [750f4bacd3262376ced3f837d8dc78f834ca233a] * grub-core/disk/diskfilter.c: Validate volumes to avoid division by zero.

Ilya Tumaykin <coacher>
Wed 11 Feb 2015 10:29:21 PM UTC, comment #4: 

git bisect start
# good: [06eadf5ebf21c8520d696c6438a976e5f7c218c3] fix double free in grub_net_recv_tcp_packet
git bisect good 06eadf5ebf21c8520d696c6438a976e5f7c218c3
# bad: [c0f529ea679bdf48cbe1c4b3dd92fb552456a1fe] arm: implement additional relocations generated by gcc 4.9 at -O3
git bisect bad c0f529ea679bdf48cbe1c4b3dd92fb552456a1fe
# bad: [b6f21bcb98f03d61087b4423261bda5d6a58fb1f] fs/cbfs: Add missing free.
git bisect bad b6f21bcb98f03d61087b4423261bda5d6a58fb1f
# bad: [44b38e49885ffcb286e796b572f3f862f3be371a] grub_menu_init_page: Avoid returning 0 geometry to avoid divisions by 0.
git bisect bad 44b38e49885ffcb286e796b572f3f862f3be371a
# good: [935863518f3a9ec12161616a31ac40e5b78bd550] grub_dmraid_nv_detect: Do not divide by zero.
git bisect good 935863518f3a9ec12161616a31ac40e5b78bd550
# bad: [4816dcac19a05a1209822015d88903faef3d6f44]       * grub-core/video/readers/jpeg.c: Avoid division by zero.
git bisect bad 4816dcac19a05a1209822015d88903faef3d6f44
# bad: [065ed900d4865fc31062f01290560ad1bc189522] grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0.
git bisect bad 065ed900d4865fc31062f01290560ad1bc189522
# good: [4200ad44fe782193a397bd0f0ab72283a6d25e89]      * grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity.
git bisect good 4200ad44fe782193a397bd0f0ab72283a6d25e89
# good: [111ab3b9cc4ffbf0901d0303872d80a7e1c08a20] osdep/linux/blocklist.c (grub_install_get_blocklist): Check blocksize validity.
git bisect good 111ab3b9cc4ffbf0901d0303872d80a7e1c08a20
# first bad commit: [065ed900d4865fc31062f01290560ad1bc189522] grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0.

Ilya Tumaykin <coacher>
Sat 07 Feb 2015 09:43:45 PM UTC, comment #3: 

I've added a couple of debug prints before the line that causes the problem:
  grub_warn "$path"
  grub_warn "${grub_probe} -t fs $path 2>&1"
  grub_warn "`"${grub_probe}" -t fs "$path" 2>&1`"

Here's how output of grub2-mkconfig looks now:

Generating grub configuration file ...
Warning: /usr/share/grub/unicode.pf2
Warning: /usr/sbin/grub2-probe -t fs /usr/share/grub/unicode.pf2 2>&1
Warning:   WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Warning: /usr/share/grub/ascii.pf2
Warning: /usr/sbin/grub2-probe -t fs /usr/share/grub/ascii.pf2 2>&1
Warning:   WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Warning: /usr/share/grub/unicode.pf2
Warning: /usr/sbin/grub2-probe -t fs /usr/share/grub/unicode.pf2 2>&1
Warning:   WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Warning: /usr/share/grub/ascii.pf2
Warning: /usr/sbin/grub2-probe -t fs /usr/share/grub/ascii.pf2 2>&1
Warning:   WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!

And I've attached core file for `/usr/sbin/grub2-probe -t fs /usr/share/grub/unicode.pf2` command.

(file #33029)

Ilya Tumaykin <coacher>
Sat 07 Feb 2015 01:00:19 PM UTC, comment #2: 

Please provide backtrace of grub-probe core and if possible exact commit since which you observe it.

Andrei Borzenkov <arvidjaar>
Group Member
Sat 07 Feb 2015 01:57:11 AM UTC, comment #1: 

Please ignore the previous proposed patch. Though backticks are needed additional double quotes are probably not.

Ilya Tumaykin <coacher>
Sat 07 Feb 2015 01:37:27 AM UTC, original submission:  

Hello.

Recently I've updated my live version of grub2 and now I have the following messages printed on every grub2-mkconfig invocation:

Generating grub configuration file ...
/usr/share/grub/grub-mkconfig_lib: line 56: 26488 Segmentation fault      "${grub_probe}" -t fs "$path" > /dev/null 2>&1
/usr/share/grub/grub-mkconfig_lib: line 56: 26496 Segmentation fault      "${grub_probe}" -t fs "$path" > /dev/null 2>&1
/usr/share/grub/grub-mkconfig_lib: line 56: 26515 Segmentation fault      "${grub_probe}" -t fs "$path" > /dev/null 2>&1
/usr/share/grub/grub-mkconfig_lib: line 56: 26530 Segmentation fault      "${grub_probe}" -t fs "$path" > /dev/null 2>&1

These are followed by messages about found kernel and initrd images and finished by 'done'.

The problem is missing backticks around 'if' condition on line 65 in util/grub-mkconfig_lib.in file (HEAD is c0f529ea679bdf48cbe1c4b3dd92fb552456a1fe).

Patch:

diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 29ef865..7a70f64 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -62,7 +62,7 @@ is_path_readable_by_grub ()
   fi

   # abort if file is in a filesystem we can't read
-  if "${grub_probe}" -t fs "$path" > /dev/null 2>&1 ; then : ; else
+  if "`"${grub_probe}" -t fs "$path" > /dev/null 2>&1`" ; then : ; else
     return 1
   fi

Ilya Tumaykin <coacher>

 

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

Attached Files
file #33067:  44199.patch added by arvidjaar (2KiB - text/x-patch)
file #33029:  core added by coacher (820KiB - 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 phcoder (Posted a comment)
  • -email is unavailable- added by arvidjaar (Posted a comment)
  • -email is unavailable- added by coacher (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-02-14 arvidjaar StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2015-02-13 arvidjaar Attached File- Added 44199.patch, #33067
    2015-02-07 coacher Attached File- Added core, #33029
    2015-02-07 arvidjaar StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code