All of lore.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; 19+ 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] 19+ messages in thread
* Re: [linux-lvm] Re: [RFLART] kdev_t in ioctls
@ 2002-01-15 20:44 ` Andries.Brouwer
  0 siblings, 0 replies; 19+ messages in thread
From: Andries.Brouwer @ 2002-01-15 14:46 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] 19+ messages in thread

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

Thread overview: 19+ 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 12:04 ` [linux-lvm] " Linus Torvalds
2002-01-14 18:01   ` Linus Torvalds
2002-01-13 17:17   ` [linux-lvm] " Joe Thornber
2002-01-15  6:27     ` Joe Thornber
2002-01-14 12:09   ` Christoph Hellwig
2002-01-14 18:08     ` Christoph Hellwig
2002-01-14 12:14     ` Christoph Hellwig
2002-01-14 18:13       ` Christoph Hellwig
2002-01-14 12:45       ` Alan Cox
2002-01-14 18:56         ` Alan Cox
2002-01-14 12:47         ` Christoph Hellwig
2002-01-14 18:45           ` Christoph Hellwig
2002-01-14 12:53           ` Linus Torvalds
2002-01-14 18:50             ` Linus Torvalds
2002-01-14 12:21   ` Alexander Viro
2002-01-14 18:20     ` Alexander Viro
  -- strict thread matches above, loose matches on Subject: below --
2002-01-15 14:46 [linux-lvm] " Andries.Brouwer
2002-01-15 20:44 ` Andries.Brouwer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.