public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFLART] kdev_t in ioctls
@ 2002-01-14 17:56 Alexander Viro
  2002-01-14 18:01 ` Linus Torvalds
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Viro @ 2002-01-14 17:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

	Linus, at least some ioctls (e.g. lvm ones) pass kdev_t from/to
userland.  While the common policy with ioctls is "anything goes", this
kind of abuse is IMNSHO over the top.

	Example: ioctl(fd, VG_CREATE, ptr) expects the following:
at ptr -
struct {
	/* bunch of sane fields */
        struct proc_dir_entry *proc;	/* ignored */
        pv_t *pv[ABS_MAX_PV + 1];
        lv_t *lv[ABS_MAX_LV + 1];
      	/* bunch of stuff */
}

and pointers in the second array are to the following:
struct {
	/* lots of stuff */
        kdev_t lv_dev;
	/* lots of other stuff */
}

They _are_ dereferenced and values of ptr->lv[i]->lv_dev are stored in
kernel data structures.  And used afterwards.  As kdev_t.

The same goes for the rest of LVM ioctls - pretty much all of them
pull such stunts.  I'm not going to comment on harmless gross indecencies
like struct proc_dir_entry * passed from the userland (and fortunately
ignored), but kdev_t instances are _not_ harmless.

Public statement along the lines "any API that passes kdev_t values
across the kernel boundary is unacceptable" would be a nice thing...


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [linux-lvm] Re: [RFLART] kdev_t in ioctls
@ 2002-01-15 20:44 Andries.Brouwer
  0 siblings, 0 replies; 10+ messages in thread
From: Andries.Brouwer @ 2002-01-15 20:44 UTC (permalink / raw)
  To: hch, torvalds; +Cc: alan, linux-kernel, linux-lvm, viro


    On Mon, 14 Jan 2002, Christoph Hellwig wrote:
    >
    > I know - still it makes Linus' suggestion not work on ~90% of the
    > systems.

    It doesn't matter if user-land compilation breaks. As long as old binaries
    work (and they will), we're fine.

    User-land was _already_ broken. By virtue of using a type that it should
    NOT have used.

    If you want to use __kernel_dev_t, go ahead.

            Linus

Yes. As everyone knows, one should not use kernel includes.
On the other hand, having local copies of everything is also
a bad habit, to be avoided when possible.
With Linux it is generally impossible to avoid going to local
copies, but so far losetup survived with the construction

% cat loop.h
#include <linux/posix_types.h>
#undef dev_t
#define dev_t __kernel_dev_t
#include <linux/loop.h>
#undef dev_t
%

Yecch.

(This is terribly ugly, but the alternative may be even worse:
lots of #ifdef's testing architecture etc.)

It is a pity that dev_t, a type that is not used anywhere in the
kernel except at the interface with user space, is a different
type from what user space uses.

Andries

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

end of thread, other threads:[~2002-01-15 20:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-14 17:56 [RFLART] kdev_t in ioctls Alexander Viro
2002-01-14 18:01 ` Linus Torvalds
2002-01-13 17:17   ` [linux-lvm] " Joe Thornber
2002-01-14 18:08   ` Christoph Hellwig
2002-01-14 18:13     ` Christoph Hellwig
2002-01-14 18:56       ` Alan Cox
2002-01-14 18:45         ` Christoph Hellwig
2002-01-14 18:50           ` Linus Torvalds
2002-01-14 18:20   ` Alexander Viro
  -- strict thread matches above, loose matches on Subject: below --
2002-01-15 20:44 [linux-lvm] " Andries.Brouwer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox