From owner-svn-src-all@FreeBSD.ORG Tue Apr 13 18:53:39 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D363C1065672; Tue, 13 Apr 2010 18:53:39 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A97088FC15; Tue, 13 Apr 2010 18:53:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3DIrdbx035081; Tue, 13 Apr 2010 18:53:39 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3DIrdOT035078; Tue, 13 Apr 2010 18:53:39 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201004131853.o3DIrdOT035078@svn.freebsd.org> From: Jaakko Heinonen Date: Tue, 13 Apr 2010 18:53:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206560 - head/sys/fs/devfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Tue, 13 Apr 2010 18:53:39 -0000 Author: jh Date: Tue Apr 13 18:53:39 2010 New Revision: 206560 URL: http://svn.freebsd.org/changeset/base/206560 Log: - Ignore and report duplicate and empty device names in devfs_populate_loop() instead of causing erratic behavior. Currently make_dev(9) can't fail, so there is no way to report an error to make_dev(9) callers. - Disallow using "." and ".." in device path names. It didn't work previously but now it is reported rather than panicing. - Treat multiple sequential slashes as single in device path names. Discussed with: pjd Modified: head/sys/fs/devfs/devfs_devs.c head/sys/fs/devfs/devfs_int.h Modified: head/sys/fs/devfs/devfs_devs.c ============================================================================== --- head/sys/fs/devfs/devfs_devs.c Tue Apr 13 18:46:18 2010 (r206559) +++ head/sys/fs/devfs/devfs_devs.c Tue Apr 13 18:53:39 2010 (r206560) @@ -408,6 +408,9 @@ devfs_populate_loop(struct devfs_mount * continue; KASSERT((cdp->cdp_flags & CDP_ACTIVE), ("Bogons, I tell ya'!")); + if (cdp->cdp_flags & CDP_INVALID) + continue; + if (dm->dm_idx <= cdp->cdp_maxdirent && cdp->cdp_dirents[dm->dm_idx] != NULL) { de = cdp->cdp_dirents[dm->dm_idx]; @@ -425,6 +428,8 @@ devfs_populate_loop(struct devfs_mount * dd = dm->dm_rootdir; s = cdp->cdp_c.si_name; for (;;) { + while (*s == '/') + s++; for (q = s; *q != '/' && *q != '\0'; q++) continue; if (*q != '/') @@ -434,6 +439,24 @@ devfs_populate_loop(struct devfs_mount * de = devfs_vmkdir(dm, s, q - s, dd, 0); s = q + 1; dd = de; + if (dd->de_flags & (DE_DOT | DE_DOTDOT)) + break; + } + + /* + * XXX: Ignore duplicate and empty device names. + * XXX: Currently there is no way to report the error to + * XXX: the make_dev(9) caller. + */ + if (dd->de_dirent->d_type != DT_DIR || + dd->de_flags & (DE_DOT | DE_DOTDOT) || q - s < 1 || + devfs_find(dd, s, q - s) != NULL) { + dev_lock(); + cdp->cdp_flags |= CDP_INVALID; + dev_unlock(); + printf("%s: %s: invalid or duplicate device name\n", + __func__, cdp->cdp_c.si_name); + return (1); } de = devfs_newdirent(s, q - s); Modified: head/sys/fs/devfs/devfs_int.h ============================================================================== --- head/sys/fs/devfs/devfs_int.h Tue Apr 13 18:46:18 2010 (r206559) +++ head/sys/fs/devfs/devfs_int.h Tue Apr 13 18:53:39 2010 (r206560) @@ -55,6 +55,7 @@ struct cdev_priv { u_int cdp_flags; #define CDP_ACTIVE (1 << 0) #define CDP_SCHED_DTR (1 << 1) +#define CDP_INVALID (1 << 2) u_int cdp_inuse; u_int cdp_maxdirent;