Bug 2185564
| Summary: | [RHEL9] get Segmentation fault failed when add partition | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | guazhang <guazhang> | |
| Component: | libblockdev | Assignee: | Vojtech Trefny <vtrefny> | |
| Status: | CLOSED ERRATA | QA Contact: | guazhang <guazhang> | |
| Severity: | unspecified | Docs Contact: | ||
| Priority: | unspecified | |||
| Version: | 9.2 | CC: | bcl, vtrefny | |
| Target Milestone: | rc | Keywords: | Triaged | |
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
|
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | libblockdev-2.28-6.el9 | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 2207500 (view as bug list) | Environment: | ||
| Last Closed: | 2023-11-07 08:25:07 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: | ||
| Embargoed: | ||||
|
Description
guazhang@redhat.com
2023-04-10 09:26:20 UTC
Moving to parted for further investigation. Having a full backtrace would be better to tell where exactly the problem is, but this is most likely caused by using MSDOS partition table[1] which is limited to 2 TiB and sdc here is 7.3 TiB. Maybe we should check this in libblockdev before trying to create the partition table and return an error, but I think this shouldn't cause a segfault in libparted. [1] https://gitlab.cee.redhat.com/kernel-qe/kernel/-/blob/master/storage/dm-crypt/cryptsetup_libblockdev/luks.py#L722 Yeah, I need more info. Can you reproduce this on the cmdline for example? Or get a traceback with the debuginfo package installed so it tells more about exactly where it crashed. Also, libparted has a pile of internal checks for unexpected situations, so it is possible for it to trigger an assert() if it is given bad data by the caller. Hi,
update MSDOS to GPT that works well.
bd.part.create_table(disk, bd.PartTableType.GPT, False)
>>> o.add_part('/dev/sda')
[2023-04-16 20:14:12] INFO: will add a part table
[2023-04-16 20:14:12] INFO: have create /dev/sda1
'/dev/sda1'
the cmd fdisk/parted add a partition successful.
parted -s /dev/sdb mkpart primary 513M 12288M
Is 12288M the same end it is trying to make with o.add_part? I tried to cause errors using a 8TiB qcow2 image and pyparted, and no matter what I did it properly raised an exception when trying to make partitions larger than what msdos supports. So without an actual traceback or reproducer there isn't much I can do to debug this. It's possible that whatever you are doing is feeding wrong sizes to libparted, but you should be getting an exception, not a coredump. HI,
[root@storageqe-105 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 7.3T 0 disk
└─sda1 8:1 0 5G 0 part
sdb 8:16 0 7.3T 0 disk
sdc 8:32 0 7.3T 0 disk
sdd 8:48 0 7.3T 0 disk
sde 8:64 0 7.3T 0 disk
sdf 8:80 0 7.3T 0 disk
sdg 8:96 0 558.4G 0 disk
├─sdg1 8:97 0 1G 0 part /boot
└─sdg2 8:98 0 557.4G 0 part
├─rhel_storageqe--105-root 253:0 0 70G 0 lvm /
├─rhel_storageqe--105-swap 253:1 0 7.6G 0 lvm [SWAP]
└─rhel_storageqe--105-home 253:2 0 479.7G 0 lvm /home
sdh 8:112 0 7.3T 0 disk
sr0 11:0 1 1024M 0 rom
```
def add_part(self, disk, size=5):
if not isinstance(size,int):
self._print("FAIL: input wrong size type, please input int type, default is G")
return
self.init_disk(disk)
self._print("INFO: will add a part table")
bd.part.create_table(disk, bd.PartTableType.MSDOS, False)
ps=bd.part.create_part(disk, bd.PartTypeReq.NORMAL, 2048*512, int(size) * 1024**3, bd.PartAlign.OPTIMAL )
if not ps.path :
self._print("FAIL: can not get part")
return
self._print("INFO: have create %s" % ps.path)
return ps.path
```
the add_part will add 5G partition as default.
[root@storageqe-105 cryptsetup_libblockdev]# parted /dev/sdb
GNU Parted 3.5
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]?
Start? 0
End? 5G
Warning: The resulting partition is not properly aligned for best performance: 1s % 2048s != 0s
Ignore/Cancel? Ignore
(parted) print
Model: ATA ST8000NM000A-2KE (scsi)
Disk /dev/sdb: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 512B 5000MB 5000MB primary ext2
(parted) quit
Information: You may need to update /etc/fstab.
[root@storageqe-105 cryptsetup_libblockdev]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 7.3T 0 disk
└─sda1 8:1 0 5G 0 part
sdb 8:16 0 7.3T 0 disk
└─sdb1 8:17 0 4.7G 0 part
sdc 8:32 0 7.3T 0 disk
sdd 8:48 0 7.3T 0 disk
sde 8:64 0 7.3T 0 disk
sdf 8:80 0 7.3T 0 disk
sdg 8:96 0 558.4G 0 disk
├─sdg1 8:97 0 1G 0 part /boot
└─sdg2 8:98 0 557.4G 0 part
├─rhel_storageqe--105-root 253:0 0 70G 0 lvm /
├─rhel_storageqe--105-swap 253:1 0 7.6G 0 lvm [SWAP]
└─rhel_storageqe--105-home 253:2 0 479.7G 0 lvm /home
sdh 8:112 0 7.3T 0 disk
sr0 11:0 1 1024M 0 rom
[root@storageqe-105 cryptsetup_libblockdev]#
[root@storageqe-105 cryptsetup_libblockdev]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 7.3T 0 disk
└─sda1 8:1 0 5G 0 part
sdb 8:16 0 7.3T 0 disk
sdc 8:32 0 7.3T 0 disk
sdd 8:48 0 7.3T 0 disk
sde 8:64 0 7.3T 0 disk
sdf 8:80 0 7.3T 0 disk
sdg 8:96 0 558.4G 0 disk
├─sdg1 8:97 0 1G 0 part /boot
└─sdg2 8:98 0 557.4G 0 part
├─rhel_storageqe--105-root 253:0 0 70G 0 lvm /
├─rhel_storageqe--105-swap 253:1 0 7.6G 0 lvm [SWAP]
└─rhel_storageqe--105-home 253:2 0 479.7G 0 lvm /home
sdh 8:112 0 7.3T 0 disk
sr0 11:0 1 1024M 0 rom
[root@storageqe-105 cryptsetup_libblockdev]# parted -s /dev/sdb mkpart primary 0 5G
Warning: The resulting partition is not properly aligned for best performance: 1s % 2048s != 0s
[root@storageqe-105 cryptsetup_libblockdev]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 7.3T 0 disk
└─sda1 8:1 0 5G 0 part
sdb 8:16 0 7.3T 0 disk
└─sdb1 8:17 0 4.7G 0 part
sdc 8:32 0 7.3T 0 disk
sdd 8:48 0 7.3T 0 disk
sde 8:64 0 7.3T 0 disk
sdf 8:80 0 7.3T 0 disk
sdg 8:96 0 558.4G 0 disk
├─sdg1 8:97 0 1G 0 part /boot
└─sdg2 8:98 0 557.4G 0 part
├─rhel_storageqe--105-root 253:0 0 70G 0 lvm /
├─rhel_storageqe--105-swap 253:1 0 7.6G 0 lvm [SWAP]
└─rhel_storageqe--105-home 253:2 0 479.7G 0 lvm /home
sdh 8:112 0 7.3T 0 disk
sr0 11:0 1 1024M 0 rom
[root@storageqe-105 cryptsetup_libblockdev]#
I installed the parted and libbd_part debug files, gdb, and turned on coredump in order to debug this.
What's happening is libbd_part is passing a null pointer into libparted:
#0 ped_geometry_set_start (geom=0x0, start=2048) at cs/geom.c:183
183 return ped_geometry_set (geom, start, geom->end - start + 1);
The libbd_part code calling it looks like this:
843 geom = ped_disk_get_max_partition_geometry (disk, part, constr);
844 if (!ped_geometry_set_start (geom, start)) {
libbd_part is not checking geom for NULL before passing it to ped_geometry_set_start, which assumes geom is valid, tries to get the geom->end value and crashes.
Thank you for the help, I posted a fix upstream. Hi, I test the fixed package but looks get the error, is it expected ? libblockdev-2.28-6.el9.x86_64 >>> o.add_part('/dev/sdb') [2023-05-17 20:44:59] INFO: will add a part table Traceback (most recent call last): File "/usr/lib64/python3.9/site-packages/gi/overrides/BlockDev.py", line 1093, in wrapped ret = orig_obj(*args, **kwargs) gi.repository.GLib.GError: g-bd-part-error-quark: Failed to create geometry for partition on device '/dev/sdb' (partition length of 15628050432 sectors exceeds the msdos-partition-table-imposed maximum of 4294967295) (2) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/kernel-master/storage/dm-crypt/cryptsetup_libblockdev/luks.py", line 730, in add_part ps=bd.part.create_part(disk, bd.PartTypeReq.NORMAL, 2048*512, int(size) * 1024**3, bd.PartAlign.OPTIMAL ) File "/usr/lib64/python3.9/site-packages/gi/overrides/BlockDev.py", line 1115, in wrapped raise transform[1](msg) gi.overrides.BlockDev.PartError: Failed to create geometry for partition on device '/dev/sdb' (partition length of 15628050432 sectors exceeds the msdos-partition-table-imposed maximum of 4294967295) >>> Yes, this is expected. The msdos partition table is limited to 2 TiB, it can be created on a bigger device but you won't then be able to create a partition exceeding the 2 TiB limit which is what the error says (15628050432 sectors is approximately 7.3 TiB). Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (libblockdev bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2023:6342 |