GNU bug report logs - #57513
[PATCH] installer: Fix segfault on double logical partition removal.

Previous Next

Package: guix-patches;

Reported by: Josselin Poiret <dev <at> jpoiret.xyz>

Date: Wed, 31 Aug 2022 21:24:01 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57513 in the body.
You can then email your comments to 57513 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#57513; Package guix-patches. (Wed, 31 Aug 2022 21:24:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Josselin Poiret <dev <at> jpoiret.xyz>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 31 Aug 2022 21:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Josselin Poiret <dev <at> jpoiret.xyz>
To: guix-patches <at> gnu.org
Cc: Josselin Poiret <dev <at> jpoiret.xyz>
Subject: [PATCH] installer: Fix segfault on double logical partition removal.
Date: Wed, 31 Aug 2022 23:22:55 +0200
* gnu/installer/parted.scm (auto-partition!): Avoid removing logical
partitions twice.
---
 gnu/installer/parted.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm
index 641a1f45e8..84fdbe24fb 100644
--- a/gnu/installer/parted.scm
+++ b/gnu/installer/parted.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2018, 2019 Mathieu Othacehe <m.othacehe <at> gmail.com>
 ;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2022 Josselin Poiret <dev <at> jpoiret.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -983,6 +984,11 @@ (define* (auto-partition! disk
     (for-each
      (lambda (partition)
        (and (data-partition? partition)
+            ;; Do not remove logical partitions ourselves, since
+            ;; disk-remove-partition* will remove all the logical partitions
+            ;; residing on an extended partition, which would lead to a
+            ;; double-remove and ensuing SEGFAULT.
+            (not (logical-partition? partition))
             (disk-remove-partition* disk partition)))
      non-boot-partitions)
 

base-commit: 47c11772dfe840a536ed7ec438fe832878f51054
-- 
2.37.2





Reply sent to Mathieu Othacehe <othacehe <at> gnu.org>:
You have taken responsibility. (Thu, 01 Sep 2022 16:50:01 GMT) Full text and rfc822 format available.

Notification sent to Josselin Poiret <dev <at> jpoiret.xyz>:
bug acknowledged by developer. (Thu, 01 Sep 2022 16:50:02 GMT) Full text and rfc822 format available.

Message #10 received at 57513-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Josselin Poiret <dev <at> jpoiret.xyz>
Cc: 57513-done <at> debbugs.gnu.org
Subject: Re: bug#57513: [PATCH] installer: Fix segfault on double logical
 partition removal.
Date: Thu, 01 Sep 2022 18:48:51 +0200
Hey,

> * gnu/installer/parted.scm (auto-partition!): Avoid removing logical
> partitions twice.

I was able to reproduce the issue by creating an extended partition
containing a single logical partition using the manual partitioning tool
then, the automatic one right after.

It resulted in a segfault, which is fixed by your patch, that's a very
nice catch!

Pushed as 4989f6acff3b3fcfbd9dde3e3c2767bd2cd6d49e.

Thanks,

Mathieu




Information forwarded to guix-patches <at> gnu.org:
bug#57513; Package guix-patches. (Thu, 01 Sep 2022 19:17:02 GMT) Full text and rfc822 format available.

Message #13 received at 57513-done <at> debbugs.gnu.org (full text, mbox):

From: Josselin Poiret <dev <at> jpoiret.xyz>
To: Mathieu Othacehe <othacehe <at> gnu.org>
Cc: 57513-done <at> debbugs.gnu.org
Subject: Re: bug#57513: [PATCH] installer: Fix segfault on double logical
 partition removal.
Date: Thu, 01 Sep 2022 21:16:02 +0200
Hey Mathieu,

Mathieu Othacehe <othacehe <at> gnu.org> writes:

> I was able to reproduce the issue by creating an extended partition
> containing a single logical partition using the manual partitioning tool
> then, the automatic one right after.
>
> It resulted in a segfault, which is fixed by your patch, that's a very
> nice catch!

I have to thank KE0VVT on IRC, who provided a core dump file!  This was
surprisingly easier to debug than I thought, for those interested, I
built the installer using the same Guix commit, and loaded the guile
core dump file in gdb.  I then used `guix build parted
--with-debug-info=parted` and loaded the resulting libparted.so library
using `info sections` to find out where the .text of libparted.so was
loaded in the core file, and `add-symbol-file
/gnu/store/path/to/libparted.so 0xaddress` to load the symbols.  That
way, I could see that ped_disk_remove_partition was invoked for a disk
that had an empty partition list, hence leading me to this double remove
problem!

> Pushed as 4989f6acff3b3fcfbd9dde3e3c2767bd2cd6d49e.
>
> Thanks,
>
> Mathieu

Thank you for reviewing this so fast!

Best,
-- 
Josselin Poiret




Information forwarded to guix-patches <at> gnu.org:
bug#57513; Package guix-patches. (Fri, 02 Sep 2022 07:52:02 GMT) Full text and rfc822 format available.

Message #16 received at 57513-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Josselin Poiret <dev <at> jpoiret.xyz>
Cc: 57513-done <at> debbugs.gnu.org
Subject: Re: bug#57513: [PATCH] installer: Fix segfault on double logical
 partition removal.
Date: Fri, 02 Sep 2022 09:50:51 +0200
Hey,

> I have to thank KE0VVT on IRC, who provided a core dump file!  This was
> surprisingly easier to debug than I thought, for those interested, I
> built the installer using the same Guix commit, and loaded the guile
> core dump file in gdb.  I then used `guix build parted
> --with-debug-info=parted` and loaded the resulting libparted.so library
> using `info sections` to find out where the .text of libparted.so was
> loaded in the core file, and `add-symbol-file
> /gnu/store/path/to/libparted.so 0xaddress` to load the symbols.  That
> way, I could see that ped_disk_remove_partition was invoked for a disk
> that had an empty partition list, hence leading me to this double remove
> problem!

I remember resorting to way less convenient solutions in the past to
achieve something similar. Feel free to add this little memo to the
documentation or as a code comment if you have the opportunity :).

Thanks again,

Mathieu




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 30 Sep 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 209 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.