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

* Re: [patch] raw: don't allow the creation of a raw device with minor number 0
  2007-01-12 16:32 [patch] raw: don't allow the creation of a raw device with minor number 0 Jeff Moyer
@ 2007-01-12 22:41 ` Jan Engelhardt
  2007-01-12 22:58   ` jmoyer
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Engelhardt @ 2007-01-12 22:41 UTC (permalink / raw)
  To: Jeff Moyer; +Cc: Linux Kernel Mailing List, Steven Fernandez, Andrew Morton


On Jan 12 2007 11:32, Jeff Moyer wrote:

>Date: Fri, 12 Jan 2007 11:32:11 -0500
>From: Jeff Moyer <jmoyer@redhat.com>
>To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
>Cc: Steven Fernandez <sfernand@redhat.com>, Andrew Morton <akpm@osdl.org>
>Subject: [patch] raw: don't allow the creation of a raw device with minor
>    number 0
>
>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:

No idea what to say about this... probably:

  What:   RAW driver (CONFIG_RAW_DRIVER)
  When:   December 2005
  Why:    declared obsolete since kernel 2.6.3
          O_DIRECT can be used instead
  Who:    Adrian Bunk <bunk@stusta.de>



	-`J'
-- 

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

* Re: [patch] raw: don't allow the creation of a raw device with minor number 0
  2007-01-12 22:41 ` Jan Engelhardt
@ 2007-01-12 22:58   ` jmoyer
  2007-01-28 20:23     ` Dave Jones
  0 siblings, 1 reply; 5+ messages in thread
From: jmoyer @ 2007-01-12 22:58 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Linux Kernel Mailing List, Steven Fernandez, Andrew Morton

==> Regarding Re: [patch] raw: don't allow the creation of a raw device with minor number 0; Jan Engelhardt <jengelh@linux01.gwdg.de> adds:

jengelh> On Jan 12 2007 11:32, Jeff Moyer wrote:

>> Date: Fri, 12 Jan 2007 11:32:11 -0500
>> From: Jeff Moyer <jmoyer@redhat.com>
>> To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
>> Cc: Steven Fernandez <sfernand@redhat.com>, Andrew Morton <akpm@osdl.org>
>> Subject: [patch] raw: don't allow the creation of a raw device with minor
>> number 0
>> 
>> 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:

jengelh> No idea what to say about this... probably:

jengelh>   What:   RAW driver (CONFIG_RAW_DRIVER)
jengelh>   When:   December 2005
jengelh>   Why:    declared obsolete since kernel 2.6.3
jengelh>           O_DIRECT can be used instead
jengelh>   Who:    Adrian Bunk <bunk@stusta.de>

It's still present, still used, and so would benefit from being fixed, in
my opinion.

Cheers,

Jeff

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

* Re: [patch] raw: don't allow the creation of a raw device with minor number 0
  2007-01-12 22:58   ` jmoyer
@ 2007-01-28 20:23     ` Dave Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Jones @ 2007-01-28 20:23 UTC (permalink / raw)
  To: jmoyer
  Cc: Jan Engelhardt, Linux Kernel Mailing List, Steven Fernandez,
	Andrew Morton

On Fri, Jan 12, 2007 at 05:58:41PM -0500, jmoyer@redhat.com wrote:
 > ==> Regarding Re: [patch] raw: don't allow the creation of a raw device with minor number 0; Jan Engelhardt <jengelh@linux01.gwdg.de> adds:
 > 
 > jengelh> On Jan 12 2007 11:32, Jeff Moyer wrote:
 > 
 > >> 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:
 > 
 > jengelh> No idea what to say about this... probably:
 > 
 > jengelh>   What:   RAW driver (CONFIG_RAW_DRIVER)
 > jengelh>   When:   December 2005
 > jengelh>   Why:    declared obsolete since kernel 2.6.3
 > jengelh>           O_DIRECT can be used instead
 > jengelh>   Who:    Adrian Bunk <bunk@stusta.de>
 > 
 > It's still present, still used, and so would benefit from being fixed, in
 > my opinion.

Given the tirade against O_DIRECT on linux-kernel earlier this month,
it has me wondering about the validity of this entry.

Every time we've tried to deprecate this driver in Fedora/RHEL, we've
had enough people complain that we've ended up having to turn it back on.
(And I'm fairly sure other distros have been in the same position).
Some vendors seem way too attached to the older semantics than having
to rewrite their apps to use O_DIRECT, and unnecessarily breaking them
so that we can throw away a 306 line driver in the name of cleanliness
seems a bit gratuitous.

		Dave

-- 
http://www.codemonkey.org.uk

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

* Re: [patch] raw: don't allow the creation of a raw device with minor number 0
       [not found]     ` <7IoP7-5nQ-13@gated-at.bofh.it>
@ 2007-01-30 15:52       ` Bodo Eggert
  0 siblings, 0 replies; 5+ messages in thread
From: Bodo Eggert @ 2007-01-30 15:52 UTC (permalink / raw)
  To: Dave Jones, Dave Jones, jmoyer, Jan Engelhardt,
	Linux Kernel Mailing List, Steven Fernandez, Andrew Morton

Dave Jones <davej@redhat.com> wrote:
> On Fri, Jan 12, 2007 at 05:58:41PM -0500, jmoyer@redhat.com wrote:

>  > jengelh>   What:   RAW driver (CONFIG_RAW_DRIVER)
>  > jengelh>   When:   December 2005
>  > jengelh>   Why:    declared obsolete since kernel 2.6.3
>  > jengelh>           O_DIRECT can be used instead
>  > jengelh>   Who:    Adrian Bunk <bunk@stusta.de>
>  > 
>  > It's still present, still used, and so would benefit from being fixed, in
>  > my opinion.

ACK, it's a bug, the patch is there, and AFAIR it's simple and correct. Maybe
it is suitable for the stable branch, too. If the RAW driver isn't removed,
it should be applied.

> Given the tirade against O_DIRECT on linux-kernel earlier this month,
> it has me wondering about the validity of this entry.

O_DIRECT on devices is accepted by Linus, since it has much less corner
cases.

> Every time we've tried to deprecate this driver in Fedora/RHEL, we've
> had enough people complain that we've ended up having to turn it back on.
> (And I'm fairly sure other distros have been in the same position).
> Some vendors seem way too attached to the older semantics than having
> to rewrite their apps to use O_DIRECT, and unnecessarily breaking them
> so that we can throw away a 306 line driver in the name of cleanliness
> seems a bit gratuitous.

It must be hard to add #ifndef O_DIRECT / #define O_DIRECT 0 / #endif
and to add O_DIRECT to the apropiate open calls ...

(I peeked into the driver, and it seems it's just a wrapper creating an alias
 and opening the associated block-device O_DIRECT.)
-- 
We are all born ignorant, but one must work hard to remain stupid.
        -- Benjamin Franklin

Friß, Spammer: zOfbszC@c7h.7eggert.dyndns.org dr@mnpqOUpA.7eggert.dyndns.org

^ 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 --
2007-01-12 16:32 [patch] raw: don't allow the creation of a raw device with minor number 0 Jeff Moyer
2007-01-12 22:41 ` Jan Engelhardt
2007-01-12 22:58   ` jmoyer
2007-01-28 20:23     ` Dave Jones
     [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       ` Bodo Eggert

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