Bug 2116505

Summary: Partition type may be unexpectedly changed when using libparted
Product: Red Hat Enterprise Linux 9 Reporter: Brian Lane <bcl>
Component: partedAssignee: Brian Lane <bcl>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: high Docs Contact:
Priority: unspecified    
Version: 9.1CC: jstodola
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: parted-3.5-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 11:19:34 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:
Attachments:
Description Flags
reproducer source none

Description Brian Lane 2022-08-08 16:19:30 UTC
Description of problem:
parted 3.5 changed the way that flags are handled in order to support the ability to set arbitrary partition types and guids. In normal use there should be no issues, but if a user of the library calls ped_partition_set_system after the initial partition setup the partition type will be changed to the default for the filesystem, possibly removing the type set based on the flags.

Version-Release number of selected component (if applicable):
parted-3.5-1


Additional info:

Currently working on a fix for this, will update when it is available.

Comment 2 Brian Lane 2022-08-09 22:50:14 UTC
Created attachment 1904583 [details]
reproducer source

Here's a small C program to test for the problem.

Install gcc and parted's header files:

dnf install -y gcc parted-devel

Create 2 disk image files:

fallocate -l 10M disk-gpt.img
fallocate -l 10M disk-msdos.img

Build the test, linking to parted:

gcc -lparted test-set_system.c -o run-test

./run-test

On parted 3.5-1 the output will have all of the flags set to OFF.

When the bug is fixed the output will have bios_grub ON for gpt and bls_boot ON for msdos.

Comment 6 Jan Stodola 2022-08-16 15:45:02 UTC
[root@localhost ~]# rpm -q parted
parted-3.5-2.el9.x86_64
[root@localhost ~]# gcc -lparted test-set_system.c -o run-test
[root@localhost ~]# ./run-test

== GPT
fs_type = ext4
           boot = OFF
           root = OFF
           swap = OFF
         hidden = OFF
           raid = OFF
            lvm = OFF
            lba = OFF
     hp-service = OFF
           palo = OFF
           prep = OFF
        msftres = OFF
      bios_grub = ON
        atvrecv = OFF
           diag = OFF
    legacy_boot = OFF
       msftdata = OFF
           irst = OFF
            esp = OFF
chromeos_kernel = OFF
       bls_boot = OFF
     linux-home = OFF

== MSDOS
fs_type = ext4
           boot = OFF
           root = OFF
           swap = OFF
         hidden = OFF
           raid = OFF
            lvm = OFF
            lba = OFF
     hp-service = OFF
           palo = OFF
           prep = OFF
        msftres = OFF
      bios_grub = OFF
        atvrecv = OFF
           diag = OFF
    legacy_boot = OFF
       msftdata = OFF
           irst = OFF
            esp = OFF
chromeos_kernel = OFF
       bls_boot = ON
     linux-home = OFF
[root@localhost ~]#


Marking as Verified:Tested

Comment 10 Jan Stodola 2022-08-18 15:32:45 UTC
Checked that parted-3.5-2.el9 is in nightly compose RHEL-9.1.0-20220817.6

Moving to VERIFIED

Comment 12 errata-xmlrpc 2022-11-15 11:19:34 UTC
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 (parted 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-2022:8342