misc/143058: [patch] make mdconfig -o reserve default for malloc-backed memory disks

Nikos Vassiliadis nvass9573 at gmx.com
Thu Jan 21 16:40:07 UTC 2010

>Number:         143058
>Category:       misc
>Synopsis:       [patch] make mdconfig -o reserve default for malloc-backed memory disks
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 21 16:40:06 UTC 2010
>Originator:     Nikos Vassiliadis
>Release:        9.0-CURRENT
FreeBSD lab.localdomain 9.0-CURRENT FreeBSD 9.0-CURRENT #1: Fri Jan  8 12:01:55 EET 2010     root at lab.localdomain:/usr/obj/usr/src/sys/LAB  i386

Creating and filling a big malloc-backed memory disk is a way to panic the system. This could be easily avoided if the reseve option became the default for malloc disks.
mdconfig -at malloc -s 200m
dd if=/dev/zero of=/dev/md0
The attached patch adds reserve to the defaults for malloc disks

Patch attached with submission follows:

Index: src/sbin/mdconfig/mdconfig.8
RCS file: /home/ncvs/src/sbin/mdconfig/mdconfig.8,v
retrieving revision 1.44
diff -u -r1.44 mdconfig.8
--- src/sbin/mdconfig/mdconfig.8	10 Jan 2009 17:17:18 -0000	1.44
+++ src/sbin/mdconfig/mdconfig.8	21 Jan 2010 16:12:10 -0000
@@ -91,8 +91,8 @@
 .Xr malloc 9 .
 This limits the size to the malloc bucket limit in the kernel.
 If the
-.Fl o Cm reserve
-option is not set, creating and filling a large
+.Fl o Cm noreserve
+option is set, creating and filling a large
 malloc-backed memory disk is a very easy way to
 panic a system.
 .It Cm vnode
Index: src/sbin/mdconfig/mdconfig.c
RCS file: /home/ncvs/src/sbin/mdconfig/mdconfig.c,v
retrieving revision 1.57
diff -u -r1.57 mdconfig.c
--- src/sbin/mdconfig/mdconfig.c	10 Jan 2009 17:17:18 -0000	1.57
+++ src/sbin/mdconfig/mdconfig.c	21 Jan 2010 16:12:10 -0000
@@ -115,7 +115,7 @@
 			if (!strcmp(optarg, "malloc")) {
 				mdio.md_type = MD_MALLOC;
-				mdio.md_options = MD_AUTOUNIT | MD_COMPRESS;
+				mdio.md_options = MD_AUTOUNIT | MD_COMPRESS | MD_RESERVE;
 			} else if (!strcmp(optarg, "preload")) {
 				mdio.md_type = MD_PRELOAD;
 				mdio.md_options = 0;


More information about the freebsd-bugs mailing list