Date: Fri, 4 Jan 2013 12:06:59 +0000 (UTC) From: Jaakko Heinonen <jh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r245038 - in stable/9: sbin/mdconfig sys/dev/md Message-ID: <201301041206.r04C6x8E021793@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jh Date: Fri Jan 4 12:06:59 2013 New Revision: 245038 URL: http://svnweb.freebsd.org/changeset/base/245038 Log: MFC r243372: 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 Modified: stable/9/sbin/mdconfig/mdconfig.c stable/9/sys/dev/md/md.c Directory Properties: stable/9/sbin/mdconfig/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sbin/mdconfig/mdconfig.c ============================================================================== --- stable/9/sbin/mdconfig/mdconfig.c Fri Jan 4 11:57:27 2013 (r245037) +++ stable/9/sbin/mdconfig/mdconfig.c Fri Jan 4 12:06:59 2013 (r245038) @@ -62,7 +62,7 @@ usage(void) " mdconfig -d -u unit [-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"); @@ -115,9 +115,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; - mdio.md_options = 0; } else if (!strcmp(optarg, "vnode")) { mdio.md_type = MD_VNODE; mdio.md_options = MD_CLUSTER | MD_AUTOUNIT | MD_COMPRESS; Modified: stable/9/sys/dev/md/md.c ============================================================================== --- stable/9/sys/dev/md/md.c Fri Jan 4 11:57:27 2013 (r245037) +++ stable/9/sys/dev/md/md.c Fri Jan 4 12:06:59 2013 (r245038) @@ -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) { @@ -1186,8 +1165,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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301041206.r04C6x8E021793>