public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Hans-Jürgen Koch" <hjk@linutronix.de>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	linux-kernel@vger.kernel.org, torvalds@osdl.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Benedikt Spranger <b.spranger@linutronix.de>
Subject: Re: Flaws with "UIO: Add the User IO core code" (with patch)
Date: Sat, 28 Apr 2007 20:52:45 +0200	[thread overview]
Message-ID: <200704282052.45489.hjk@linutronix.de> (raw)
In-Reply-To: <20070428001923.15074234@the-village.bc.nu>

Am Samstag 28 April 2007 01:19 schrieb Alan Cox:
> > +static ssize_t uio_read(struct file *filep, char __user *buf,
> > +			size_t count, loff_t *ppos)
> > +{
> > +	struct uio_listener *listener = filep->private_data;
> > +	struct uio_device *idev = listener->dev;
> > +	DECLARE_WAITQUEUE(wait, current);
> > +	ssize_t retval;
> > +	int event_count;
> > +
> > +	if (idev->info->irq == UIO_IRQ_NONE)
> > +		return -EIO;
> > +
> > +	if (count != sizeof(int))
> > +		return -EINVAL;
> 
> AFAIK we don't currently have any platform that runs binaries with
> different sizes of "int" but this is a) an unsigned value anyway, and b)
> should be a fixed type (eg u32)

I reviewed the code once more and find it OK. There is only one legal
value for the parameter "count" of uio_read(), and that's sizeof(int).
The data that is actually read is the element "event" of struct uio_device,
which is of type atomic_t. The latter has the size of an int.

Unfortunately, the fact that the read count _must_ be sizeof(int) is not
mentioned in the documentation. I'll send a patch for that ASAP.

> 
> Otherwise it looks ok at the momenmt, although there is a real nasty
> waiting for anyone who tries to use it. At the point open is possible or
> IRQs can be enabled you are safe in the core merged as idev->info is
> always valid, but any driver module trying to go back via info->uio_dev
> has a NULL pointer for an early IRQ or open event.

This patch should fix it:


Index: linux-2.6.22-rc/drivers/uio/uio.c
===================================================================
--- linux-2.6.22-rc.orig/drivers/uio/uio.c	2007-04-28 20:01:02.000000000 +0200
+++ linux-2.6.22-rc/drivers/uio/uio.c	2007-04-28 20:15:00.000000000 +0200
@@ -633,6 +633,8 @@
 	if (ret)
 		goto err_uio_dev_add_attributes;
 
+	info->uio_dev = idev;
+
 	if (idev->info->irq >= 0) {
 		ret = request_irq(idev->info->irq, uio_interrupt,
 				  idev->info->irq_flags, idev->info->name, idev);
@@ -640,7 +642,6 @@
 			goto err_request_irq;
 	}
 
-	info->uio_dev = idev;
 	return 0;
 
 err_request_irq:


Thanks for your review,
Hans


  parent reply	other threads:[~2007-04-28 18:53 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-27 22:49 [GIT PATCH] UIO patches for 2.6.21 Greg KH
2007-04-27 22:50 ` [PATCH 1/3] UIO: Add the User IO core code Greg Kroah-Hartman
2007-04-27 22:50   ` [PATCH 2/3] UIO: Documentation Greg Kroah-Hartman
2007-04-27 22:50     ` [PATCH 3/3] UIO: Hilscher CIF card driver Greg Kroah-Hartman
2007-04-29 19:44       ` [PATCH 3/3] UIO: Hilscher CIF card driver (with patch) Hans-Jürgen Koch
2007-05-01 23:42     ` [PATCH 2/3] UIO: Documentation Randy Dunlap
2007-05-02  8:41       ` Hans-Jürgen Koch
2007-05-02 20:52         ` Randy Dunlap
2007-05-02 22:00           ` Hans-Jürgen Koch
2007-05-02 23:37             ` Randy Dunlap
2007-05-03  5:37               ` Greg KH
2007-05-03  6:39                 ` Hans-Jürgen Koch
2007-05-04  9:37                   ` Hans-Jürgen Koch
2007-05-07 17:46                     ` Randy Dunlap
2007-05-07 20:01                       ` Hans-Jürgen Koch
2007-04-27 23:19   ` Flaws with "UIO: Add the User IO core code" Alan Cox
2007-04-28 11:39     ` Thomas Gleixner
2007-04-28 18:52     ` Hans-Jürgen Koch [this message]
2007-04-28 20:24       ` Flaws with "UIO: Add the User IO core code" (with patch) Alan Cox
2007-04-28 20:38         ` Thomas Gleixner
2007-04-28 21:03         ` Hans-Jürgen Koch
2007-04-28 21:08           ` Thomas Gleixner
2007-04-28 21:14             ` Flaws with "UIO: Add the User IO core code" Hans-Jürgen Koch
2007-04-29 22:18               ` Flaws with "UIO: Add the User IO core code" (with patch) Hans-Jürgen Koch
2007-04-27 23:04 ` [GIT PATCH] UIO patches for 2.6.21 Andrew Morton
2007-04-27 23:11   ` Greg KH
2007-04-28 11:38     ` Thomas Gleixner
2007-04-27 23:26   ` Alan Cox
2007-04-28  0:28   ` Hans-Jürgen Koch
2007-04-28 13:00 ` Matthieu CASTET
2007-04-28 13:49   ` Hans-Jürgen Koch
2007-04-28 19:56 ` Bill Davidsen
2007-04-28 20:02   ` Thomas Gleixner
2007-04-28 20:03   ` Hans-Jürgen Koch
2007-04-28 20:15     ` Alan Cox
2007-04-28 20:31       ` Thomas Gleixner
2007-04-29  1:23         ` Greg KH
2007-04-29  8:30           ` Thomas Gleixner
2007-04-29 12:09             ` Jan Engelhardt
2007-04-29 16:27               ` Alan Cox
2007-05-07 20:02             ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200704282052.45489.hjk@linutronix.de \
    --to=hjk@linutronix.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=b.spranger@linutronix.de \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox