[PATCH] protect against buggy drivers

From: Stephen Hemminger
Date: Fri Oct 08 2004 - 11:56:07 EST


# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/10/08 09:52:03-07:00 shemminger@xxxxxxxxxxxxxxxxx
# Protect against bad driver writers who pass invalid names when
# setting up character devices.
#
# fs/char_dev.c
# 2004/10/08 09:51:52-07:00 shemminger@xxxxxxxxxxxxxxxxx +5 -0
# Protect against bad driver writers who pass invalid names when
# setting up character devices.
#
diff -Nru a/fs/char_dev.c b/fs/char_dev.c
--- a/fs/char_dev.c 2004-10-08 09:52:15 -07:00
+++ b/fs/char_dev.c 2004-10-08 09:52:15 -07:00
@@ -196,6 +196,11 @@
char *s;
int err = -ENOMEM;

+ if (name == NULL || *name == '\0' ||
+ strlen(name) >= KOBJ_NAME_LEN ||
+ !strcmp(name, ".") || !strcmp(name, ".."))
+ return -EINVAL;
+
cd = __register_chrdev_region(major, 0, 256, name);
if (IS_ERR(cd))
return PTR_ERR(cd);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/