From owner-svn-src-all@FreeBSD.ORG Wed Nov 21 16:56:48 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DFAE9134; Wed, 21 Nov 2012 16:56:47 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C453D8FC12; Wed, 21 Nov 2012 16:56:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qALGulEd095557; Wed, 21 Nov 2012 16:56:47 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qALGulru095555; Wed, 21 Nov 2012 16:56:47 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201211211656.qALGulru095555@svn.freebsd.org> From: Jaakko Heinonen Date: Wed, 21 Nov 2012 16:56:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243372 - in head: sbin/mdconfig sys/dev/md X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Nov 2012 16:56:48 -0000 Author: jh Date: Wed Nov 21 16:56:47 2012 New Revision: 243372 URL: http://svnweb.freebsd.org/changeset/base/243372 Log: Disallow attaching preloaded memory disks via ioctl. - The feature is dangerous because the kernel code didn't check validity of the memory address provided from user space. - It seems that mdconfig(8) never really supported attaching preloaded memory disks. - Preloaded memory disks are automatically attached during md(4) initialization. Thus there shouldn't be much use for the feature. PR: kern/169683 Discussed on: freebsd-hackers Modified: head/sbin/mdconfig/mdconfig.c head/sys/dev/md/md.c Modified: head/sbin/mdconfig/mdconfig.c ============================================================================== --- head/sbin/mdconfig/mdconfig.c Wed Nov 21 09:50:31 2012 (r243371) +++ head/sbin/mdconfig/mdconfig.c Wed Nov 21 16:56:47 2012 (r243372) @@ -84,7 +84,7 @@ usage(void) " mdconfig -r -u unit -s size [-o [no]force]\n" " mdconfig -l [-v] [-n] [-u unit]\n" " mdconfig file\n"); - fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n"); + fprintf(stderr, "\t\ttype = {malloc, vnode, swap}\n"); fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n"); fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n"); fprintf(stderr, "\t\t %%dk (kB), %%dm (MB), %%dg (GB) or\n"); @@ -148,8 +148,6 @@ main(int argc, char **argv) if (!strcmp(optarg, "malloc")) { mdio.md_type = MD_MALLOC; mdio.md_options |= MD_AUTOUNIT | MD_COMPRESS; - } else if (!strcmp(optarg, "preload")) { - mdio.md_type = MD_PRELOAD; } else if (!strcmp(optarg, "vnode")) { mdio.md_type = MD_VNODE; mdio.md_options |= MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS; Modified: head/sys/dev/md/md.c ============================================================================== --- head/sys/dev/md/md.c Wed Nov 21 09:50:31 2012 (r243371) +++ head/sys/dev/md/md.c Wed Nov 21 16:56:47 2012 (r243372) @@ -854,27 +854,6 @@ mdinit(struct md_s *sc) DEVSTAT_ALL_SUPPORTED, DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX); } -/* - * XXX: we should check that the range they feed us is mapped. - * XXX: we should implement read-only. - */ - -static int -mdcreate_preload(struct md_s *sc, struct md_ioctl *mdio) -{ - - if (mdio->md_options & ~(MD_AUTOUNIT | MD_FORCE)) - return (EINVAL); - if (mdio->md_base == 0) - return (EINVAL); - sc->flags = mdio->md_options & MD_FORCE; - /* Cast to pointer size, then to pointer to avoid warning */ - sc->pl_ptr = (u_char *)(uintptr_t)mdio->md_base; - sc->pl_len = (size_t)sc->mediasize; - return (0); -} - - static int mdcreate_malloc(struct md_s *sc, struct md_ioctl *mdio) { @@ -1238,8 +1217,12 @@ xmdctlioctl(struct cdev *dev, u_long cmd error = mdcreate_malloc(sc, mdio); break; case MD_PRELOAD: - sc->start = mdstart_preload; - error = mdcreate_preload(sc, mdio); + /* + * We disallow attaching preloaded memory disks via + * ioctl. Preloaded memory disks are automatically + * attached in g_md_init(). + */ + error = EOPNOTSUPP; break; case MD_VNODE: sc->start = mdstart_vnode;