Bug 2181826 - hardlink segfaults in strlen() on armv7
Summary: hardlink segfaults in strlen() on armv7
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 36
Hardware: armv7hl
OS: Linux
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: ARMTracker
TreeView+ depends on / blocked
Reported: 2023-03-26 10:50 UTC by Dan Horák
Modified: 2023-05-25 17:23 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2023-05-25 17:23:07 UTC
Type: Bug

Attachments (Terms of Use)

Description Dan Horák 2023-03-26 10:50:54 UTC
Description of problem:
/usr/bin/hardlink segfaults in strlen() on armv7, see bellow. I know it's late for Fedora, but this report might be valuable from upstream point of view. It needs the "-vvv" option passed to hardlink to reproduce.

[dan@helios dir]$ gdb /usr/bin/hardlink
GNU gdb (GDB) Fedora 12.1-2.fc36
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "armv7hl-redhat-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/hardlink...

This GDB supports auto-downloading debuginfo from the following URLs:
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
Reading symbols from /home/dan/.cache/debuginfod_client/f655da68516ba60ae83a3bdd2e3dae184fe32546/debuginfo...
(gdb) set args -n -c -vv .
(gdb) run
Starting program: /usr/bin/hardlink -n -c -vv .
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Mode:                     dry-run
Method:                   sha256
Files:                    3
Linked:                   0 files
Compared:                 0 xattrs
Compared:                 0 files
Saved:                    0 B
Duration:                 0.001277 seconds
[Inferior 1 (process 529) exited normally]
(gdb) set args -n -c -vvv .
(gdb) run
Starting program: /usr/bin/hardlink -n -c -vvv .
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Scanning [device/inode/links]:

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
126		ldrd	data1a, data1b, [src]
(gdb) where
#0  strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
#1  0xb6e5c948 in __vfprintf_internal (s=0xb6f7bd50 <_IO_2_1_stdout_>, format=format@entry=0x0, ap=..., mode_flags=<optimized out>) at vfprintf-internal.c:1517
#2  0xb6f094a0 in ___vfprintf_chk (fp=<optimized out>, flag=flag@entry=1, format=format@entry=0x0, ap=..., ap@entry=...) at vfprintf_chk.c:29
#3  0x0040271c in vfprintf (__ap=..., __fmt=0x0, __stream=<optimized out>) at /usr/include/bits/stdio2.h:135
#4  jlog (level=level@entry=JLOG_VERBOSE2, format=0x407ad0 " %5zu: [%ld/%ld/%zu] %s") at misc-utils/hardlink.c:230
#5  0x004054e4 in inserter (ftwbuf=0xbefff0e4, typeflag=<optimized out>, sb=0xbeffeff0, fpath=0x41deb8 "/opt/data/scratch/t460/pmtuts.zip") at misc-utils/hardlink.c:814
#6  inserter (fpath=0x41deb8 "/opt/data/scratch/t460/pmtuts.zip", sb=sb@entry=0xbeffeff0, typeflag=<optimized out>, ftwbuf=ftwbuf@entry=0xbefff0e4) at misc-utils/hardlink.c:783
#7  0xb6ee72ac in process_entry (data=data@entry=0xbefff0d0, dir=dir@entry=0xbefff090, name=<optimized out>, name@entry=0x41ef23 "pmtuts.zip", namlen=<optimized out>, 
    d_type=<optimized out>) at ftw.c:472
#8  0xb6ee777c in ftw_dir (data=data@entry=0xbefff0d0, st=0x0, st@entry=0xbefff108, old_dir=old_dir@entry=0x0) at ftw.c:551
#9  0xb6ee80d4 in ftw_startup (dir=<optimized out>, is_nftw=is_nftw@entry=1, func=func@entry=0x40530c <inserter>, descriptors=descriptors@entry=20, flags=flags@entry=1) at ftw.c:771
#10 0xb6ee820c in __new_nftw64 (path=<optimized out>, func=func@entry=0x40530c <inserter>, descriptors=descriptors@entry=20, flags=flags@entry=1) at ftw.c:844
#11 0x00401bf8 in main (argc=5, argv=0xbefff404) at misc-utils/hardlink.c:1374

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

How reproducible:

Steps to Reproduce:
1. enter a directory with some files
2. /usr/bin/hardlink -n -c -vvv .

Actual results:

Expected results:
report about hardlinked files

Additional info:
The system is a Helios4 board based on a Marvell Armada SoC (https://kobol.io/helios4/).

[dan@helios t460]$ cat /proc/cpuinfo 
processor	: 0
model name	: ARMv7 Processor rev 1 (v7l)
BogoMIPS	: 800.00
Features	: half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x4
CPU part	: 0xc09
CPU revision	: 1

processor	: 1
model name	: ARMv7 Processor rev 1 (v7l)
BogoMIPS	: 800.00
Features	: half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x4
CPU part	: 0xc09
CPU revision	: 1

Hardware	: Marvell Armada 380/385 (Device Tree)
Revision	: 0000
Serial		: 0000000000000000

Comment 1 Carlos O'Donell 2023-04-04 13:54:46 UTC
May you please reach out to the Fedora Arm community and discuss the issue?

This is not likely a glibc issue but possibly a toolchain issue.

Note that __fmt is 0x0 in the call chain and it fails, so this does seem like a toolchain issue.

I'm going to switch to util-linux to ask them if they've seen this reported before.

Comment 2 Carlos O'Donell 2023-04-04 13:55:18 UTC

Have you seen this before for armv7?

Comment 3 Dan Horák 2023-04-08 07:33:46 UTC
Based on the feedback on the arm mailing list I believe we can confirm there is an issue on F-36, but not in F-35. The hardlink binary from F-35 runs well (no crash) on F-36, which I think rules out glibc. The F 35->36 transition also means gcc 11->12 transition, so there could be a compiler issue in gcc 12.

Comment 4 Karel Zak 2023-04-12 10:55:18 UTC
I have never seen it before.

The problematic code (in hardlink.c) is:

        jlog(JLOG_VERBOSE2, " %5zu: [%" PRIu64 "/%" PRIu64 "/%zu] %s",
                        stats.files, sb->st_dev, sb->st_ino,
                        (size_t) sb->st_nlink, fpath);

And jlog() is implemented as:

        va_start(args, format);
        vfprintf(stdout, format, args);

The fpath (used for %s in the format) comes from nftw().

Comment 5 Ben Cotton 2023-04-25 18:20:46 UTC
This message is a reminder that Fedora Linux 36 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 36 on 2023-05-16.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '36'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 36 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 6 Ludek Smid 2023-05-25 17:23:07 UTC
Fedora Linux 36 entered end-of-life (EOL) status on 2023-05-16.

Fedora Linux 36 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.