LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch] raw: don't allow the creation of a raw device with minor number 0
@ 2007-01-12 16:32 Jeff Moyer
  2007-01-12 22:41 ` Jan Engelhardt
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Moyer @ 2007-01-12 16:32 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Steven Fernandez, Andrew Morton

Hi,

Minor number 0 (under the raw major) is reserved for the rawctl device
file, which is used to query, set, and unset raw device bindings.
However, the ioctl interface does not protect the user from specifying
a raw device with minor number 0:

$ sudo ./raw /dev/raw/raw0 /dev/VolGroup00/swap
/dev/raw/raw0:  bound to major 253, minor 2
$ ls -l /dev/rawctl
ls: /dev/rawctl: No such file or directory
$ ls -l /dev/raw/raw0 
crw------- 1 root root 162, 0 Jan 12 10:51 /dev/raw/raw0
$ sudo ./raw -qa
Cannot open master raw device '/dev/rawctl' (No such file or directory)

As you can see, this prevents any further raw operations from
succeeding.  The fix (from Steve Fernandez) is quite simple--do not
allow the allocation of minor number 0.

Thanks!

Jeff

diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 645e20a..1f0d7c6 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -154,7 +154,7 @@ static int raw_ctl_ioctl(struct inode *i
 			goto out;
 		}
 
-		if (rq.raw_minor < 0 || rq.raw_minor >= MAX_RAW_MINORS) {
+		if (rq.raw_minor <= 0 || rq.raw_minor >= MAX_RAW_MINORS) {
 			err = -EINVAL;
 			goto out;
 		}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-01-30 15:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <7CxBM-2pk-23@gated-at.bofh.it>
     [not found] ` <7CDnP-30W-9@gated-at.bofh.it>
     [not found]   ` <7CDxA-3cL-9@gated-at.bofh.it>
     [not found]     ` <7IoP7-5nQ-13@gated-at.bofh.it>
2007-01-30 15:52       ` [patch] raw: don't allow the creation of a raw device with minor number 0 Bodo Eggert
2007-01-12 16:32 Jeff Moyer
2007-01-12 22:41 ` Jan Engelhardt
2007-01-12 22:58   ` jmoyer
2007-01-28 20:23     ` Dave Jones

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).