lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c384c5ea0805231344j77f61941u229206d04c1ef948@mail.gmail.com>
Date:	Fri, 23 May 2008 22:44:42 +0200
From:	"Leon Woestenberg" <leon.woestenberg@...il.com>
To:	"Hans J. Koch" <hjk@...utronix.de>
Cc:	"Uwe Kleine-König" <Uwe.Kleine-Koenig@...i.com>,
	linux-kernel@...r.kernel.org,
	"Greg Kroah-Hartman" <gregkh@...e.de>,
	"Jan Altenberg" <jan.altenberg@...utronix.de>,
	"Thomas Gleixner" <tglx@...utronix.de>,
	"Magnus Damm" <magnus.damm@...il.com>
Subject: Re: [PATCH 1/1] UIO: Add a write() function to enable/disable interrupts

Hello,

On Fri, May 23, 2008 at 1:55 PM, Hans J. Koch <hjk@...utronix.de> wrote:
> +static ssize_t uio_write(struct file *filep, const char __user *buf,
> +                       size_t count, loff_t *ppos)
> +{
> +       struct uio_listener *listener = filep->private_data;
> +       struct uio_device *idev = listener->dev;
> +       ssize_t retval;
> +       s32 irq_on;
> +
> +       if (idev->info->irq == UIO_IRQ_NONE)
> +               return -EIO;
> +
> +       if (count != sizeof(s32))
> +               return -EINVAL;
> +
> +       if (!idev->info->irqcontrol)
> +               return -ENOSYS;
> +
> +       if (copy_from_user(&irq_on, buf, count))
> +               return -EFAULT;
> +
> +       retval = idev->info->irqcontrol(idev->info, irq_on);
> +
> +       return retval ? retval : sizeof(s32);
> +}
> +

Shouldn't this be more future-proof, what if we need to abuse write()
for something else in the future?

I would suggest a check for ppos to be 0 (zero) as well, just to be
sure and future-proof and backwards-safe.

Regards,
-- 
Leon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ