public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] utterly bogus userland API in infinibad
@ 2005-09-16 18:11 Al Viro
  2005-09-16 19:31 ` Roland Dreier
  0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2005-09-16 18:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, rolandd

Exhibit A:

	opening uverbs... is done by ib_uverbs_open() (in
drivers/infinib*d/core/uverbs_main.c).   Aside of a number of obvious
leaks, it does a number of calls of ib_uverbs_event_init().  Each of
those does something amazingly bogus:
	* allocates a descriptor
	* allocates struct file
	* associates that struct file with root of their pseudo-fs
	* inserts it into caller's descriptor table
... and leaves an unknown number of those if open() fails, while we
are at it.  With zero indications for caller and no way to find out.

	What's more, you _can_ get those descriptors afterwards, if open()
had succeeded.  All you need to do is...

Exibit B:
	... write() to said descriptor.  Buffer should contain a struct
that will be interpreted.  Results will be written to user memory, at the
addresses contained in that struct.  Said results might include the
descriptors shat upon by open().  Nice way to hide an ioctl(), folks...

Note that this "interface" assumes that only original opener will write
to that file - for anybody else descriptors obviously will not make any
sense.

BTW, due to the way we do opens, if another thread sharing descriptor
table will guess the number of first additional descriptor to be opened
and just loops doing close() on it, we'll actually get our ib_uverbs_file
kfreed right under us.  

May I ask who had come up with that insanity?  Aside of inherent ugliness
and abuse of fs syscalls, it simply doesn't work.  E.g. leaks on failed
open() are going to be fun to fix...

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

end of thread, other threads:[~2005-09-19 22:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-16 18:11 [RFC] utterly bogus userland API in infinibad Al Viro
2005-09-16 19:31 ` Roland Dreier
2005-09-16 20:37   ` Al Viro
2005-09-16 23:54     ` Roland Dreier
2005-09-17  0:03       ` David S. Miller
2005-09-17  0:08         ` Roland Dreier
2005-09-19 22:25       ` Roland Dreier

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