Bug 1069393

Summary: systemd-208-14.fc20 segfaults if /proc/swaps does not exist
Product: [Fedora] Fedora Reporter: Matt Mullins <mokomull>
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: johannbg, lnykryn, msekleta, plautrba, systemd-maint, vpavlin, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: systemd-208-15.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-08 03:34:12 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
patch to check for ENOENT and return from swap_dispatch_reload and swap_enumerate none

Description Matt Mullins 2014-02-24 22:22:59 UTC
Description of problem:

With a kernel config that does not include CONFIG_SWAP, /proc/swaps does not exist.  systemd-208-14.fc20 segfaults while enumerating swap devices in this case.  systemd-208-9.fc20 worked.

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

208-14.fc20

How reproducible:

Reliably.

Steps to Reproduce:
1. Build kernel without CONFIG_SWAP.
2. Install systemd-208-14.fc20
3. Reboot the system or systemctl daemon-reexec

Actual results:

Feb 24 13:10:47 fedora systemd[1]: Reexecuting.
Feb 24 13:10:47 fedora systemd[1]: systemd 208 running in system mode. (+PAM +LIBWRAP +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ)
Feb 24 13:10:47 fedora systemd[1]: Detected virtualization 'kvm'.
Feb 24 13:10:48 fedora kernel: systemd[1]: segfault at 0 ip 00007f047f4f0b61 sp 00007fff60cd4b50 error 4 in libc-2.18.so[7f047f47c000+1b4000]
Feb 24 13:10:48 fedora systemd[1]: Caught <SEGV>, dumped core as pid 7646.
Feb 24 13:10:48 fedora systemd[1]: Freezing execution.

Expected results:

Feb 24 14:17:32 fedora systemd[1]: Reexecuting.
Feb 24 14:17:32 fedora systemd[1]: systemd 208 running in system mode. (+PAM +LIBWRAP +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ)
Feb 24 14:17:32 fedora systemd[1]: Detected virtualization 'kvm'.

Additional info:

Backtrace is:
(gdb) bt
#0  0x00007f047f84a62b in raise (sig=sig@entry=11) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
#1  0x00007f04813959ae in crash (sig=11) at ../src/core/main.c:152
#2  <signal handler called>
#3  __GI_rewind (fp=0x0) at rewind.c:35
#4  0x00007f04813b6fee in swap_load_proc_swaps (m=m@entry=0x7f04822f9560, set_flags=set_flags@entry=false) at ../src/core/swap.c:1033
#5  0x00007f04813b7361 in swap_enumerate (m=0x7f04822f9560) at ../src/core/swap.c:1255
#6  0x00007f0481398554 in manager_enumerate (m=0x7f04822f9560) at ../src/core/manager.c:789
#7  0x00007f048139afdc in manager_startup (m=0x7f04822f9560, serialization=0x7f04822ef2c0, fds=0x7f04822f7550) at ../src/core/manager.c:905
#8  0x00007f0481393827 in main (argc=4, argv=0x7fff60cd5578) at ../src/core/main.c:1583

It looks like the refactoring in SOURCES/0147-core-do-not-segfault-if-swap-activity-happens-when-p.patch has caused swap_enumerate to continue if fopen() sets errno=ENOENT.  Previously, the error would cause swap_enumerate to terminate successfully, but now it is open_proc_swaps that completes "successfully".  Both swap_dispatch_reload and swap_enumerate continue even though m->proc_swaps is NULL.

Comment 1 Matt Mullins 2014-02-25 00:49:57 UTC
Created attachment 867215 [details]
patch to check for ENOENT and return from swap_dispatch_reload and swap_enumerate

Attaching a patch that works against a machine without /proc/swaps.

I also reproduced #969795 on 208-9.fc20 by creating a bogus swap unit and attempting to start it (without CONFIG_SWAP enabled).  I verified that with this patch, systemd successfully boots the machine without swap, and trying to enable the bogus swap unit also does not segfault.

Comment 2 Zbigniew Jędrzejewski-Szmek 2014-02-25 01:54:28 UTC
Thank you for the patch. I'll go out in the next update.

Comment 3 Fedora Update System 2014-03-05 21:37:51 UTC
systemd-208-15.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/systemd-208-15.fc20

Comment 4 Fedora Update System 2014-03-07 06:27:17 UTC
Package systemd-208-15.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing systemd-208-15.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-3522/systemd-208-15.fc20
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2014-03-08 03:34:12 UTC
systemd-208-15.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.