bin/180164: [patch][regression] swapon segfault after r252310

Fabian Keil fk at fabiankeil.de
Mon Jul 1 12:10:00 UTC 2013


>Number:         180164
>Category:       bin
>Synopsis:       [patch][regression] swapon segfault after r252310
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 01 12:10:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Fabian Keil
>Release:        HEAD
>Organization:
>Environment:
FreeBSD r500.local 10.0-CURRENT FreeBSD 10.0-CURRENT #586 r+49efc8c: Mon Jul  1 11:10:27 CEST 2013     fk at r500.local:/usr/obj/usr/src/sys/ZOEY  amd64

>Description:
The attached patch fixes a swapon segfault after r252310.

BTW, I was surprised that the meaning of my fstab entry:
/dev/ada0s1b.eli  none  swap  sw  0  0
changed.

It now enables authentication which reduces the available swap space.
If this change is kept, I think it might be worth an UPDATING entry.
>How-To-Repeat:
fk at r500 ~ $sudo gdb76 --args swapon /dev/ada0s1b.eli 
GNU gdb (GDB) 7.6 [GDB v7.6 for FreeBSD]
[...]
(gdb) r
Starting program: /sbin/swapon /dev/ada0s1b.eli

Program received signal SIGSEGV, Segmentation fault.
strlen (str=0x0) at /usr/src/lib/libc/string/strlen.c:100
100		va = (*lp - mask01);
(gdb) where
#0  strlen (str=0x0) at /usr/src/lib/libc/string/strlen.c:100
#1  0x0000000800ab1562 in strdup (str=0x0) at /usr/src/lib/libc/string/strdup.c:46
#2  0x0000000000402351 in swap_on_off_geli (mntops=0x0, name=0x7fffffffdb6d "/dev/ada0s1b.eli", doingall=<optimized out>) at /usr/src/sbin/swapon/swapon.c:339
#3  swap_on_off (name=0x7fffffffdb6d "/dev/ada0s1b.eli", doingall=0, mntops=0x0) at /usr/src/sbin/swapon/swapon.c:242
#4  0x000000000040205c in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/sbin/swapon/swapon.c:200
>Fix:


Patch attached with submission follows:

>From 4cf8c315df4f1c5761f8a90274ba551ec1f1fa36 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk at fabiankeil.de>
Date: Mon, 1 Jul 2013 13:27:44 +0200
Subject: [PATCH] Fix segmentation fault when swap_on_off_geli() is called
 without mount options

---
 sbin/swapon/swapon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c
index cf9b979..8bcfc55 100644
--- a/sbin/swapon/swapon.c
+++ b/sbin/swapon/swapon.c
@@ -336,7 +336,7 @@ swap_on_off_geli(char *name, char *mntops, int doingall)
 	}
 	*p = '\0';
 
-	ops = strdup(mntops);
+	ops = strdup(mntops != NULL ? mntops : "");
 
 	/* Default parameters for geli(8). */
 	aalgo = aalgo_default;
-- 
1.8.2.2



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list