summaryrefslogtreecommitdiffstats
path: root/sys/fs/devfs
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2010-04-13 18:53:39 +0000
committerjh <jh@FreeBSD.org>2010-04-13 18:53:39 +0000
commit7013f95fb6468804af4df7cd4324d3a771ac0fb6 (patch)
tree5cb736a11d4da914efa73f5885d16a743a0e88c7 /sys/fs/devfs
parent3ac1019f84ed4d6ff272d87f91eae85fcfd686f8 (diff)
downloadFreeBSD-src-7013f95fb6468804af4df7cd4324d3a771ac0fb6.zip
FreeBSD-src-7013f95fb6468804af4df7cd4324d3a771ac0fb6.tar.gz
- 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
Diffstat (limited to 'sys/fs/devfs')
-rw-r--r--sys/fs/devfs/devfs_devs.c23
-rw-r--r--sys/fs/devfs/devfs_int.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
index 81b2752..79037ba 100644
--- a/sys/fs/devfs/devfs_devs.c
+++ b/sys/fs/devfs/devfs_devs.c
@@ -408,6 +408,9 @@ devfs_populate_loop(struct devfs_mount *dm, int cleanup)
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 *dm, int cleanup)
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 *dm, int cleanup)
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);
diff --git a/sys/fs/devfs/devfs_int.h b/sys/fs/devfs/devfs_int.h
index 5a61dd4..a998061 100644
--- a/sys/fs/devfs/devfs_int.h
+++ b/sys/fs/devfs/devfs_int.h
@@ -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;
OpenPOWER on IntegriCloud