Bug 1007761

Summary: Segmentation fault when argument 'partnum' of part-get-gpt-type is too large
Product: Red Hat Enterprise Linux 7 Reporter: bfan
Component: gdiskAssignee: Tomáš Bžatek <tbzatek>
Status: CLOSED CURRENTRELEASE QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: leiwang, rjones, tsmetana, vhumpa, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gdisk-0.8.6-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1007847 (view as bug list) Environment:
Last Closed: 2014-06-13 10:02:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 1007847    
Bug Blocks:    

Description bfan 2013-09-13 09:32:00 UTC
Description of problem:
when partnum >= 1185, part-get-gpt-type will give an error.

libguestfs: error: part_get_gpt_type: sgdisk /dev/sda -i 1185: *** Segmentation fault
Register dump:

 RAX: 0000000000000000   RBX: 00000000019e6018   RCX: 0000000035383131
 RDX: 0000000000353831   RSI: 0000000000000200   RDI: 00000000019e6018
 RBP: 0000000000000000   R8 : 0000000000000000   R9 : 0000000000000002
...

but guestfish is still alive. It looks like a bug of sgdisk

 
Version-Release number of selected component (if applicable):
libguestfs-1.22.6-5.el7.x86_64
gdisk-0.8.6-1.el7.x86_64


How reproducible:
100%

 
Steps to Reproduce:
# guestfish -N fs part-disk /dev/sda gpt : part-get-gpt-type /dev/sda 1185


Actual result:
Gives a "Segmentation fault" error


Expect result:
Not return "Segmentation fault"


Additional info:
I tried "sgdisk /dev/sda -i 1185" in linux, it failed
# sgdisk /dev/sda -i 1185

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format.
***************************************************************

Segmentation fault (core dumped)

Comment 1 Richard W.M. Jones 2013-09-13 12:58:06 UTC
You were right that this is a bug in gdisk.  Easily
reproducible on the command line:

$ sgdisk /dev/sda -i 1185

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************

Segmentation fault (core dumped)

The stack trace is:

Program received signal SIGSEGV, Segmentation fault.
GPTPart::ShowDetails (this=0x851018, blockSize=512) at gptpart.cc:210
210	   if (firstLBA != 0) {
(gdb) bt
#0  GPTPart::ShowDetails (this=0x851018, blockSize=512) at gptpart.cc:210
#1  0x000000000041015e in GPTData::ShowPartDetails (
    this=this@entry=0x7fffffffc470, partNum=<optimized out>) at gpt.cc:1406
#2  0x00000000004193d1 in GPTDataCL::DoOptions (
    this=this@entry=0x7fffffffc470, argc=argc@entry=4, 
    argv=argv@entry=0x7fffffffde48) at gptcl.cc:255
#3  0x0000000000402dd6 in main (argc=4, argv=0x7fffffffde48) at sgdisk.cc:20

Comment 2 Tomáš Bžatek 2013-09-26 12:28:19 UTC
Backported changes from bug 1007847 and built gdisk-0.8.6-2.el7

Comment 5 Ludek Smid 2014-06-13 10:02:38 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.