From owner-freebsd-current@FreeBSD.ORG Sun Jan 29 13:04:42 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DE8FF16A420 for ; Sun, 29 Jan 2006 13:04:42 +0000 (GMT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 008F443D70 for ; Sun, 29 Jan 2006 13:04:35 +0000 (GMT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.11/8.12.11) with ESMTP id k0TD4ZWT005993 for ; Sun, 29 Jan 2006 05:04:35 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.11/8.12.3/Submit) id k0TD4ZXu005992 for current@freebsd.org; Sun, 29 Jan 2006 05:04:35 -0800 (PST) (envelope-from rizzo) Date: Sun, 29 Jan 2006 05:04:35 -0800 From: Luigi Rizzo To: current@freebsd.org Message-ID: <20060129050435.A5945@xorpc.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Cc: Subject: for review: sys/dev/md/md.c patch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jan 2006 13:04:43 -0000 just discovered, trying to resurrect picobsd on -current, that the compiler in 6.x/7.x has become smart and, at least with the default compilation flags, will optimize out the "end_mfs_root" string from the object. As a consequence, any checks that the preloaded module does not overflow the allocated space (looking at the 'MFS Filesystem had better STOP here' string in the patched object) will fail. The attached patch fixes the issue. Any objection if i commit it ? cheers luigi Index: md.c =================================================================== RCS file: /prova/home/ncvs/src/sys/dev/md/md.c,v retrieving revision 1.159 diff -u -p -r1.159 md.c --- md.c 31 Oct 2005 15:41:19 -0000 1.159 +++ md.c 29 Jan 2006 12:57:22 -0000 @@ -102,8 +102,13 @@ SYSCTL_INT(_debug, OID_AUTO, mddebug, CT #if defined(MD_ROOT) && defined(MD_ROOT_SIZE) /* Image gets put here: */ -static u_char mfs_root[MD_ROOT_SIZE*1024] = "MFS Filesystem goes here"; -static u_char end_mfs_root[] __unused = "MFS Filesystem had better STOP here"; +static struct { + u_char start[MD_ROOT_SIZE*1024]; + u_char end[128]; +} mfs_root = { + .start = "MFS Filesystem goes here", + .end = "MFS Filesystem had better STOP here", +}; #endif static g_init_t g_md_init; @@ -1139,7 +1144,7 @@ g_md_init(struct g_class *mp __unused) g_topology_unlock(); #ifdef MD_ROOT_SIZE sx_xlock(&md_sx); - md_preloaded(mfs_root, MD_ROOT_SIZE * 1024); + md_preloaded(mfs_root.start, MD_ROOT_SIZE * 1024); sx_xunlock(&md_sx); #endif /* XXX: are preload_* static or do they need Giant ? */