Skip to content

2.2.9: zfs share -a segfaults on musl if /etc/exports.d is missing. #17967

@alex-moch

Description

@alex-moch

System information

Type Version/Name
Distribution Name Gentoo
Distribution Version rolling/latest
Kernel Version 6.17.8-gentoo-dist
Architecture Aarch64
OpenZFS Version 2.2.9

Describe the problem you're observing

Running zfs share -a results in a segmentation fault when /etc/exports.d does not exist on musl-based systems.

Describe how to reproduce the problem

# Ensure /etc/exports.d does not exist.
rm -rf /etc/exports.d

# Trigger the crash.
zfs share -a

Expected: Command completes successfully or prints a warning
Actual: Segmentation fault

Include any warning/errors/backtraces from the system logs

strace output:

openat(AT_FDCWD, "/etc/exports.d/zfs.exports.lock", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600) = -1 ENOENT (No such file or directory)
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x27} ---
+++ killed by SIGSEGV +++

LLDB backtrace:

(lldb) bt all
* thread #1, name = 'zfs', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x27)
  * frame #0: 0x0000fffff7f7bbe4 libc.so`__strerror_l + 16
    frame #1: 0x0000fffff7eddd84 libzfs.so.4`___lldb_unnamed_symbol_6fcac + 216
    frame #2: 0x0000fffff7eddea0 libzfs.so.4`___lldb_unnamed_symbol_6fe70 + 48
    frame #3: 0x0000fffff7ebb550 libzfs.so.4`zfs_truncate_shares + 48
    frame #4: 0x0000aaaaaaac7348 zfs`___lldb_unnamed_symbol_26f58 + 1008
    frame #5: 0x0000aaaaaaabdaa4 zfs`___lldb_unnamed_symbol_1d7f4 + 688

Root Cause

This issue was introduced in commit ede037c and fixed in commit 41e55b4.

The fix exists in master but was not backported to the 2.2.x stable branch.

Request

Please backport commit 41e55b4 to the zfs-2.2-release branch for inclusion in 2.2.10.

The patch applies cleanly to 2.2.9 and resolves the segfault.

Workaround

mkdir -p /etc/exports.d/
touch /etc/exports.d/zfs.exports.lock

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: DefectIncorrect behavior (e.g. crash, hang)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions