netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Tommi Virtanen <tv@tv.debian.net>, Greg KH <greg@kroah.com>
Cc: Leann Ogasawara <ogasawara@osdl.org>,
	netdev@oss.sgi.com, linux-kernel@vger.kernel.org
Subject: [PATCH] don't allow / in class device names
Date: Fri, 13 Feb 2004 10:27:55 -0800	[thread overview]
Message-ID: <20040213102755.27cf4fcd.shemminger@osdl.org> (raw)


> [0 tv@tao /sys/class/misc]$ uname -a
> Linux tao 2.6.2-rc2 #6 Mon Jan 26 10:54:50 EET 2004 i686 GNU/Linux
> [0 tv@tao /sys/class/misc]$ echo *
> intermezzo net/tun psaux rtc uinput
> [0 tv@tao /sys/class/misc]$
>
> Seems like that's all because of this:
>
> static struct miscdevice tun_miscdev = {
>         .minor = TUN_MINOR,
>         .name = "net/tun",
>         .fops = &tun_fops
> };
>
> Name is apparently meant to be a filename, not a path.
> Don't know what should be done to it; maybe
>
> static struct miscdevice tun_miscdev = {
>         .minor = TUN_MINOR,
>         .name = "tun",
>         .fops = &tun_fops,
>         .devfs_name = "misc/net/tun",
> };
>
> But I havent tried that out.
>
> I'd suggest this, to flush out all the problems. Later,
> it can be changed to return -EINVAL or BUG_ON.
>
> --- 1.26/drivers/char/misc.c    Thu Jan 15 13:05:56 2004
> +++ edited/misc.c       Fri Feb 13 19:35:45 2004
> @@ -212,6 +212,9 @@
>  int misc_register(struct miscdevice * misc)
>  {
>         struct miscdevice *c;
> +
> +       if (misc->name && strchr(misc->name, '/'))
> +         printk("%s: name contains slash when registering %s.\n", __func__, misc->name);
>
>         down(&misc_sem);
>         list_for_each_entry(c, &misc_list, list) {
>
Don't fix it just for misc_register, the fix needs to go into class_device.

diff -Nru a/drivers/base/class.c b/drivers/base/class.c
--- a/drivers/base/class.c	Fri Feb 13 10:23:36 2004
+++ b/drivers/base/class.c	Fri Feb 13 10:23:36 2004
@@ -281,7 +281,8 @@
 	int error;
 
 	class_dev = class_device_get(class_dev);
-	if (!class_dev || !strlen(class_dev->class_id))
+	if (!class_dev || !strlen(class_dev->class_id) 
+	    || strchr(class_dev->class_id, '/'))
 		return -EINVAL;
 
 	parent = class_get(class_dev->class);

             reply	other threads:[~2004-02-13 18:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-13 18:27 Stephen Hemminger [this message]
2004-02-13 19:21 ` [PATCH] propogate errors from misc_register to caller Stephen Hemminger
2004-02-13 20:38   ` Greg KH
2004-02-20  0:23   ` Greg KH
2004-02-13 20:34 ` [PATCH] don't allow / in class device names Greg KH
2004-02-13 20:45   ` Stephen Hemminger
2004-02-13 20:59     ` Greg KH
2004-02-16 22:43       ` maximilian attems

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040213102755.27cf4fcd.shemminger@osdl.org \
    --to=shemminger@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=ogasawara@osdl.org \
    --cc=tv@tv.debian.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).