From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux1394-devel@lists.sourceforge.net
Cc: Clemens Ladisch <clemens@ladisch.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] firewire: cdev: fix information leak
Date: Wed, 07 Apr 2010 08:30:50 +0200 [thread overview]
Message-ID: <4BBC269A.6040909@s5r6.in-berlin.de> (raw)
In-Reply-To: <tkrat.30d7a4f8f7a97b2b@s5r6.in-berlin.de>
Stefan Richter wrote:
> --- a/drivers/firewire/core-cdev.c
> +++ b/drivers/firewire/core-cdev.c
> @@ -1346,41 +1346,43 @@ static int (* const ioctl_handlers[])(st
> static int dispatch_ioctl(struct client *client,
> unsigned int cmd, void __user *arg)
> {
> union ioctl_arg buffer;
> int ret;
>
> if (fw_device_is_shutdown(client->device))
> return -ENODEV;
>
> if (_IOC_TYPE(cmd) != '#' ||
> _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers))
> return -EINVAL;
>
> - if (_IOC_DIR(cmd) & _IOC_WRITE) {
> - if (_IOC_SIZE(cmd) > sizeof(buffer) ||
> - copy_from_user(&buffer, arg, _IOC_SIZE(cmd)))
> + if (_IOC_SIZE(cmd) > sizeof(buffer))
> + return -EFAULT;
I'll combine this into the preceding -EINVAL return. Cf. man ioctl.
> +
> + if (_IOC_DIR(cmd) == _IOC_READ)
> + memset(&buffer, 0, _IOC_SIZE(cmd));
> +
> + if (_IOC_DIR(cmd) & _IOC_WRITE)
> + if (copy_from_user(&buffer, arg, _IOC_SIZE(cmd)))
> return -EFAULT;
> - }
>
> ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer);
> if (ret < 0)
> return ret;
>
> - if (_IOC_DIR(cmd) & _IOC_READ) {
> - if (_IOC_SIZE(cmd) > sizeof(buffer) ||
> - copy_to_user(arg, &buffer, _IOC_SIZE(cmd)))
> + if (_IOC_DIR(cmd) & _IOC_READ)
> + if (copy_to_user(arg, &buffer, _IOC_SIZE(cmd)))
> return -EFAULT;
> - }
>
> return ret;
> }
--
Stefan Richter
-=====-==-=- -=-- --===
http://arcgraph.de/sr/
prev parent reply other threads:[~2010-04-07 6:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4BBAD1BC.2070100@ladisch.de>
[not found] ` <4BBADAA1.9050508@s5r6.in-berlin.de>
[not found] ` <4BBAF7EE.5000804@ladisch.de>
[not found] ` <4BBB8851.6000509@s5r6.in-berlin.de>
[not found] ` <tkrat.0047dfa7530926c0@s5r6.in-berlin.de>
[not found] ` <tkrat.630b7e060062afa9@s5r6.in-berlin.de>
2010-04-06 21:59 ` Stefan Richter
2010-04-07 6:30 ` Stefan Richter [this message]
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=4BBC269A.6040909@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=clemens@ladisch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®