After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762448 - Check FAT32 fs crashes GParted
Check FAT32 fs crashes GParted
Status: RESOLVED OBSOLETE
Product: gparted
Classification: Other
Component: application
0.25.0
Other Linux
: Normal major
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2016-02-22 12:52 UTC by JPT
Modified: 2020-11-15 15:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Crash log Gparted 0.19.0 (39.19 KB, text/plain)
2016-02-22 12:52 UTC, JPT
Details
disk image which crashes gparted (17.00 KB, application/octet-stream)
2016-02-23 13:31 UTC, JPT
Details
backtrace (10.21 KB, text/plain)
2016-02-23 13:31 UTC, JPT
Details

Description JPT 2016-02-22 12:52:36 UTC
Created attachment 321831 [details]
Crash log Gparted 0.19.0

Hi, 

I've got a FAT32 fs which I believe contains an infinite directory loop. This loop was created by Cyanogen Filemanager 3.0.0 (CM-12.1) when I tried to rename "folder" to "Folder".

Whenever I try to check the FS, Gparted crashes. 
fsck.fat 3.0.28 does not complain at all, and does not repair anything.
Did I use wrong fsck arguments? Any suggestion?

The attached log is from my Kubuntu installation, gparted 0.19.0. I also tried it from gparted-live-0.25.0-3-i686.iso Same result, but difficult to fetch log.
btw, where do I find the core dump?

thanks
Comment 1 Mike Fleetwood 2016-02-22 18:35:22 UTC
Hi,


If I understand you setup correctly, you have an Android device (phone,
tablet of something else) running CyanogenMod.  In such a case I expect
that the file system driver is part of the Linux kernel, and the file
manager merely requested the folder to be renamed.  I assume Cyanogen
Filemanager is running directly on the Android device with the FAT32
file system in question.

======================
libparted : 3.2
======================
*** buffer overflow detected ***: /usr/sbin/gpartedbin terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x78c4e)[0x7f73d37a5c4e]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f73d3845e8c]
/lib/x86_64-linux-gnu/libc.so.6(+0x116e80)[0x7f73d3843e80]
/lib/x86_64-linux-gnu/libparted-fs-resize.so.0(+0x42a2)[0x7f73d67802a2]
/lib/x86_64-linux-gnu/libparted-fs-resize.so.0(+0x435b)[0x7f73d678035b]
/lib/x86_64-linux-gnu/libparted-fs-resize.so.0(+0x435b)[0x7f73d678035b]
/lib/x86_64-linux-gnu/libparted-fs-resize.so.0(+0x435b)[0x7f73d678035b]
/lib/x86_64-linux-gnu/libparted-fs-resize.so.0(+0x435b)[0x7f73d678035b]
...

Looking at this fragment of the log it suggests that GParted crashed in
the GNU Parted (http://www.gnu.org/software/parted/) library:
libparted-fs-resize.so.


Q: Did you use the wrong fsck arguments?
A: GParted run this command: fsck.fat -a -w -v /dev/PTN
   Also note that as part of a check operation GParted tries to resize a
   file system to fill the partition.  This is where I suspect the crash
   is happening.


Q: Where do I find the core dump?
A: Most distros write core dumps to automatic bug reporting tools and
   suppress writing of core dumps to the local disk.


Q: Any suggestions?
A: Generate a core dump on your Kubuntu installation following the
   instructions below.


Thanks,
Mike


How to capture a backtrace from a coredump
------------------------------------------

1)  Turn off any OS core dump capturing, ensuring:
        cat /proc/sys/kernel/core_pattern
    reports just "core"

    Some methods to do this, depending on distro version, are:
    *   service abrt-ccpp stop
    *   systemctl stop abrtd
    *   sudo service apport stop

2)  Increase core dump limit and run GParted as root
    Either:
        ulimit -c unlimited
        sudo gparted
    or:
        su - root
        ulimit -c unlimited
        gparted

3)  Perform crashing action

4)  Capture backtrace

	ls -lrt core*
        which gpartedbin
        gdb `which gpartedbin` {COREFILE} --batch --quiet \
            -ex backtrace -ex quit > backtrace.log

Please paste the terminal output when running gparted and the contents
of the backtrace.log file.
Comment 2 JPT 2016-02-23 13:29:04 UTC
Ok. I did the following: 

echo core  > /proc/sys/kernel/core_pattern

$ sudo kpartx -av sample.img 
add map loop0p1 (252:0): 0 62325760 linear /dev/loop0 8192

$ ln -s  /dev/mapper/loop0p1 sample.img1
$ sudo gparted sample.img

$ ls -lrt core*
-rw------- 1 root root 33820672 Feb 23 13:56 core
$ which gpartedbin
/usr/sbin/gpartedbin

$ chown jan:jan core

$ gdb `which gpartedbin` core --batch --quiet -ex backtrace -ex quit > backtrace.log

It complains: 
55      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
Do I need the sources? of what exactly?


And I created a disk image which crashes gparted. 
I's size 100 MB, compressed 17k
I created it by copying the cyclic dir from my original disk. ln doesn't want to link dirs.
Comment 3 JPT 2016-02-23 13:31:25 UTC
Created attachment 321955 [details]
disk image which crashes gparted

you can "mount" this in gparted if you create a loopback device like this:
$ sudo kpartx -av test.img 
add map loop0p1 (252:0): 0 62325760 linear /dev/loop0 8192
$ ln -s  /dev/mapper/loop0p1 test.img1
Comment 4 JPT 2016-02-23 13:31:56 UTC
Created attachment 321956 [details]
backtrace
Comment 5 JPT 2016-02-23 13:40:01 UTC
Your assumptions regarding the smart phone are correct.

And yes if I think about it, it should be a kernel problem. Phone Kernel is version 3.4.0. I believe it is heavily modified though...

My PC's kernel simply copied the cyclic directory over, so stock Ubuntu kernel handles cyclic dirs on FAT a bit too relaxed?

Linux TUX 4.2.0-27-generic #32-Ubuntu SMP x86_64

I believe ext2 actually allows cyclic dirs?
Comment 6 Mike Fleetwood 2016-02-23 21:30:30 UTC
Thank you for the file system image, I have reproduced the crash of
GParted.  Backtrace below.  It's crashing in function
flag_tracerse_dir() in library libparted-fs-resize.  The function
recursively traverses the directory structure so it's definitely not
expecting a infinitely deep directory structure from a directory hard
linked to itself.  In fact I suspect most every tool expects the depth
of the directory tree to be limited.


Note that it is not possible to create hard linked directories on the
Linux command line on any file system because ln refuses.

# fgrep /mnt/2 /proc/self/mounts
/dev/md127p2 /mnt/2 ext2 rw,seclabel,relatime,errors=continue 0 0
# cd /mnt/2
# mkdir a
# ln a b
ln: `a': hard link not allowed for directory


Android Linux 3.4.0, CyanogenMod 12.1 and Filemanager 3.0.0 definitely
should not be allowing a directory to be hard linked to itself.  You'll
need to report that to Cyanogen.  In the mean time I'll try to make
libparted immune.

Thanks,
Mike


# ./gpartedbin /dev/loop0
======================
libparted : 2.4
======================
*** buffer overflow detected ***: ./gpartedbin terminated
...
# gdb ./gpartedbin core.11167 --batch --quiet -ex backtrace -ex quit
[New Thread 11167]
[New Thread 11170]
[Thread debugging using libthread_db enabled]
Core was generated by `./gpartedbin /dev/loop0'.
Program terminated with signal 6, Aborted.
  • #0 raise
    at ../nptl/sysdeps/unix/sysv/linux/raise.c line 64
  • #0 raise
    at ../nptl/sysdeps/unix/sysv/linux/raise.c line 64
  • #1 abort
    at abort.c line 92
  • #2 __libc_message
    at ../sysdeps/unix/sysv/linux/libc_fatal.c line 198
  • #3 __fortify_fail
    at fortify_fail.c line 32
  • #4 __chk_fail
    at chk_fail.c line 29
  • #5 strcpy
    at /usr/include/bits/string3.h line 105
  • #6 flag_traverse_dir
    at count.c line 229
  • #7 flag_traverse_dir
    at count.c line 282
  • #8 flag_traverse_dir
    at count.c line 282
  • #9 flag_traverse_dir
    at count.c line 282
  • #10 flag_traverse_dir
    at count.c line 282
  • #11 flag_traverse_dir
    at count.c line 282
  • #12 flag_traverse_dir
    at count.c line 282
  • #13 flag_traverse_dir
    at count.c line 282
  • #14 flag_traverse_dir
    at count.c line 282
  • #15 flag_traverse_dir
    at count.c line 282
  • #16 flag_traverse_dir
    at count.c line 282
  • #17 flag_traverse_dir
    at count.c line 282
  • #18 flag_traverse_dir
    at count.c line 282
  • #19 flag_traverse_dir
    at count.c line 282
  • #20 flag_traverse_dir
    at count.c line 282
  • #21 flag_traverse_dir
    at count.c line 282
  • #22 flag_traverse_dir
    at count.c line 282
  • #23 flag_traverse_dir
    at count.c line 282
  • #24 flag_traverse_dir
    at count.c line 282
  • #25 flag_traverse_dir
    at count.c line 282
  • #26 flag_traverse_dir
    at count.c line 282
  • #27 flag_traverse_dir
    at count.c line 282
  • #28 flag_traverse_dir
    at count.c line 282
  • #29 flag_traverse_dir
    at count.c line 282
  • #30 flag_traverse_dir
    at count.c line 282
  • #31 flag_traverse_dir
    at count.c line 282
  • #32 flag_traverse_dir
    at count.c line 282
  • #33 flag_traverse_dir
    at count.c line 282
  • #34 flag_traverse_dir
    at count.c line 282
  • #35 flag_traverse_dir
    at count.c line 282
  • #36 flag_traverse_dir
    at count.c line 282
  • #37 flag_traverse_dir
    at count.c line 282
  • #38 flag_traverse_dir
    at count.c line 282
  • #39 flag_traverse_dir
    at count.c line 282
  • #40 flag_traverse_dir
    at count.c line 282
  • #41 flag_traverse_dir
    at count.c line 282
  • #42 flag_traverse_dir
    at count.c line 282
  • #43 flag_traverse_dir
    at count.c line 282
  • #44 flag_traverse_dir
    at count.c line 282
  • #45 flag_traverse_dir
    at count.c line 282
  • #46 flag_traverse_dir
    at count.c line 282
  • #47 flag_traverse_dir
    at count.c line 282
  • #48 flag_traverse_dir
    at count.c line 282
  • #49 flag_traverse_dir
    at count.c line 282
  • #50 flag_traverse_dir
    at count.c line 282
  • #51 flag_traverse_dir
    at count.c line 282
  • #52 flag_traverse_dir
    at count.c line 282
  • #53 flag_traverse_dir
    at count.c line 282
  • #54 flag_traverse_dir
    at count.c line 282
  • #55 flag_traverse_dir
    at count.c line 282
  • #56 flag_traverse_dir
    at count.c line 282
  • #57 flag_traverse_dir
    at count.c line 282
  • #58 flag_traverse_dir
    at count.c line 282
  • #59 flag_traverse_dir
    at count.c line 282
  • #60 flag_traverse_dir
    at count.c line 282
  • #61 flag_traverse_dir
    at count.c line 282
  • #62 flag_traverse_dir
    at count.c line 282
  • #63 flag_traverse_dir
    at count.c line 282
  • #64 flag_traverse_dir
    at count.c line 282
  • #65 flag_traverse_dir
    at count.c line 282
  • #66 flag_traverse_dir
    at count.c line 282
  • #67 flag_traverse_dir
    at count.c line 282
  • #68 flag_traverse_dir
    at count.c line 282
  • #69 flag_traverse_dir
    at count.c line 282
  • #70 flag_traverse_dir
    at count.c line 282
  • #71 fat_collect_cluster_info
    at count.c line 325
  • #72 fat_open
    at fat.c line 238
  • #73 ped_file_system_open
    at filesys.c line 487
  • #74 GParted::GParted_Core::resize_move_filesystem_using_libparted
    at GParted_Core.cc line 2661
  • #75 GParted::GParted_Core::resize_filesystem
    at GParted_Core.cc line 2982
  • #76 GParted::GParted_Core::maximize_filesystem
    at GParted_Core.cc line 3029
  • #77 GParted::GParted_Core::apply_operation_to_disk
    at GParted_Core.cc line 741
  • #78 emit
    at /usr/include/sigc++-2.0/sigc++/signal.h line 917
  • #79 emit
    at /usr/include/sigc++-2.0/sigc++/signal.h line 2773
  • #80 GParted::Dialog_Progress::on_signal_show
    at Dialog_Progress.cc line 226
  • #81 Glib::SignalProxyNormal::slot0_void_callback(_GObject*, void*)
    from /usr/lib64/libglibmm-2.4.so.1
  • #82 g_closure_invoke
    at gclosure.c line 767
  • #83 signal_emit_unlocked_R
    at gsignal.c line 3322
  • #84 g_signal_emit_valist
    at gsignal.c line 2983
  • #85 g_signal_emit
    at gsignal.c line 3040
  • #86 IA__gtk_widget_show
    at gtkwidget.c line 3251
  • #87 IA__gtk_dialog_run
    at gtkdialog.c line 1065
  • #88 GParted::Win_GParted::activate_apply
    at Win_GParted.cc line 2884
  • #89 Glib::SignalProxyNormal::slot0_void_callback(_GObject*, void*)
    from /usr/lib64/libglibmm-2.4.so.1
  • #90 g_closure_invoke
    at gclosure.c line 767
  • #91 signal_emit_unlocked_R
    at gsignal.c line 3322
  • #92 g_signal_emit_valist
    at gsignal.c line 2983
  • #93 g_signal_emit_by_name
    at gsignal.c line 3077
  • #94 g_closure_invoke
    at gclosure.c line 767
  • #95 signal_emit_unlocked_R
    at gsignal.c line 3252
  • #96 g_signal_emit_valist
    at gsignal.c line 2983
  • #97 g_signal_emit
    at gsignal.c line 3040
  • #98 gtk_real_button_released
    at gtkbutton.c line 1712
  • #99 g_closure_invoke
    at gclosure.c line 767
  • #100 signal_emit_unlocked_R
    at gsignal.c line 3182
  • #101 g_signal_emit_valist
    at gsignal.c line 2983
  • #102 g_signal_emit
    at gsignal.c line 3040
  • #103 gtk_button_button_release
    at gtkbutton.c line 1604
  • #104 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 86
  • #105 g_closure_invoke
    at gclosure.c line 767
  • #106 signal_emit_unlocked_R
    at gsignal.c line 3290
  • #107 g_signal_emit_valist
    at gsignal.c line 2993
  • #108 g_signal_emit
    at gsignal.c line 3040
  • #109 gtk_widget_event_internal
    at gtkwidget.c line 5025
  • #110 IA__gtk_propagate_event
    at gtkmain.c line 2490
  • #111 IA__gtk_main_do_event
    at gtkmain.c line 1685
  • #112 gdk_event_dispatch
    at gdkevents-x11.c line 2403
  • #113 g_main_dispatch
    at gmain.c line 2441
  • #114 g_main_context_dispatch
    at gmain.c line 3014
  • #115 g_main_context_iterate
    at gmain.c line 3092
  • #116 g_main_loop_run
    at gmain.c line 3300
  • #117 IA__gtk_main
    at gtkmain.c line 1257
  • #118 Gtk::Main::run(Gtk::Window&)
    from /usr/lib64/libgtkmm-2.4.so.1
  • #119 main
    at main.cc line 57

Comment 7 Mike Fleetwood 2016-02-27 12:50:41 UTC
Note that the Linux link(2) system call also prevent creating hard links
to directories.

# cat t.c
#include <unistd.h>
#include <sys/stat.h>

int main(void)
{
	mkdir("a", 0755);
	link("a", "a/a");
	return 0;
}
# gcc -o t t.c
# fgrep /mnt /proc/self/mounts
/dev/sdb2 /mnt/2 ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/sdc4 /mnt/4 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0
# cd /mnt/2
# strace ~/t
...
mkdir("a", 0755)              = 0
link("a", "a/a")              = -1 EPERM (Operation not permitted)
# cd /mnt/4
# strace ~/t
...
mkdir("a", 0755)              = 0
link("a", "a/a")              = -1 EPERM (Operation not permitted)


The manal page for link(2) says that trying to create a hard link to a
directory is not allowed and will fail with EPERM error.
http://man7.org/linux/man-pages/man2/link.2.html

       int link(const char *oldpath, const char *newpath);
...
ERRORS
       ...
       EPERM  oldpath is a directory.


So either Android Linux is broken or CyanogenMod / Filemanager is
totally bypassing the the Linux kernel VFS and file system driver and
modifying the file system directly itself and is broken.
Comment 8 Mike Fleetwood 2016-02-27 13:28:05 UTC
I have examined the file system image from comment #3 a bit closer.  The
directory "keepass" is not hard linked to itself.  Instead it is a very
deep directory structure.  If I can count properly, it is 453 "keepass"
directories deep, with a relative path length of 3623 characters.

It might well be that there is an infinite loop is CyanogenMod
Filemanager and it stopped when it reached some path limit.
Comment 9 Mike Fleetwood 2016-02-28 15:41:01 UTC
I've submitted a parted patchset to resolve this bug.

[PATCH 0/2] Prevent crash resizing FAT with very deep directories
http://lists.alioth.debian.org/pipermail/parted-devel/2016-February/004800.html
Comment 10 JPT 2016-03-01 18:47:27 UTC
Cool. Thank you very much for dealing with my bug report so quickly. This way reporting bugs is fun :)

I checked the orig image. It's 453 dirs deep too. This explains why the app took so long to fail. And it is a strong hint the bug is located in the app, not the kernel.
Comment 11 Mike Fleetwood 2016-03-20 19:42:09 UTC
Patches were applied to the parted GIT repository:

lib-fs-resize: Prevent crash resizing FAT with very deep directories
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=6242ad71d855be62d99ec345e52393be86ca9900

tests: t3000-resize-fs.sh: Add very deep directory
http://git.savannah.gnu.org/cgit/parted.git/commit/?id=27b57de66c7560945cf87e5287911975939225ec


Curtis,

As parted don't release very often we should make sure that the next
GParted Live CD includes the patches even if Debian don't pick it up.

Thanks,
Mike
Comment 12 Curtis Gedak 2016-05-02 17:09:07 UTC
A custom version of libparted which includes these patches was included in GParted Live 0.26.0-1.
Comment 13 André Klapper 2020-11-13 10:41:14 UTC
bugzilla.gnome.org is being replaced by gitlab.gnome.org. We are closing all old bug reports and feature requests in GNOME Bugzilla which have not seen updates for a long time.

If you still use gparted and if you still see this bug / want this feature in a recent and currently supported version, then please feel free to report it at
https://gitlab.gnome.org/GNOME/gparted/-/issues/
by following the guidelines at
https://wiki.gnome.org/Community/GettingInTouch/BugReportingGuidelines

Thank you for creating this report and we are sorry it could not be implemented so far (volunteer workforce and time is limited).
Comment 14 Mike Fleetwood 2020-11-15 15:33:33 UTC
Parted v3.3 was released 2019-10-10 which includes the commits mentioned
in comment #11.

http://git.savannah.gnu.org/cgit/parted.git/commit/?h=v3.3&id=d6594b56a8d8e74185e11608f1b61471af7cc114
https://ftp.gnu.org/gnu/parted/