From: Greg KH <gregkh@linuxfoundation.org>
To: Dave Penkler <dpenkler@gmail.com>
Cc: peter.chen@freescale.com, teuniz@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 5/5] Add ioctls to enable and disable local controls on an instrument
Date: Sun, 24 Jan 2016 20:47:48 -0800 [thread overview]
Message-ID: <20160125044748.GC14247@kroah.com> (raw)
In-Reply-To: <20151129123743.GE7499@slacky>
On Sun, Nov 29, 2015 at 01:37:43PM +0100, Dave Penkler wrote:
> These ioctls provide support for the USBTMC-USB488 control requests
> for REN_CONTROL, GO_TO_LOCAL and LOCAL_LOCKOUT
>
> Signed-off-by: Dave Penkler <dpenkler@gmail.com>
> ---
> drivers/usb/class/usbtmc.c | 71 ++++++++++++++++++++++++++++++++++++++++++++
> include/uapi/linux/usb/tmc.h | 6 ++++
> 2 files changed, 77 insertions(+)
>
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index 3a3264c..f04a086 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -473,6 +473,62 @@ static int usbtmc488_ioctl_read_stb(struct usbtmc_device_data *data,
> return rv;
> }
>
> +static int usbtmc488_ioctl_simple(struct usbtmc_device_data *data,
> + unsigned long arg,
Same thing here with arg, so you don't have to cast it later in this
function.
> + unsigned int cmd)
> +{
> + struct device *dev = &data->intf->dev;
> + unsigned int val;
> + u8 *buffer;
> + u16 wValue;
> + int rv;
> +
> + if (!(data->usb488_caps & USBTMC488_CAPABILITY_SIMPLE))
> + return -EINVAL;
> +
> + buffer = kmalloc(8, GFP_KERNEL);
> + if (!buffer)
> + return -ENOMEM;
> +
> + if (cmd == USBTMC488_REQUEST_REN_CONTROL) {
> + rv = copy_from_user(&val, (void __user *)arg, sizeof(val));
unsigned int is different sizes on different user/kernel implementations
(32bit user, 64bit kernel.) You need to always copy an explicit size
across this boundry, you just made this ioctl really hard to implement
correctly in userspace :(
And it doesn't match the size you told userspace to use:
> +#define USBTMC488_IOCTL_REN_CONTROL _IOW(USBTMC_IOC_NR, 19, unsigned char)
sizeof(unsigned char) != (unsigned int)
Please fix this up, using the correct types (hint, you want __u8 here),
and for the other one, and resend the series.
thanks,
greg k-h
prev parent reply other threads:[~2016-01-25 4:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 12:22 [PATCH v6 0/5] usb: usbtmc: Add support for missing functions in USBTMC-USB488 spec Dave Penkler
2015-11-29 12:28 ` [PATCH v6 1/5] Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation Dave Penkler
2016-01-25 4:43 ` Greg KH
2015-11-29 12:30 ` [PATCH v6 2/5] Add support for USBTMC USB488 SRQ notification with fasync Dave Penkler
2015-11-29 12:34 ` [PATCH v6 3/5] Add support for receiving USBTMC USB488 SRQ notifications via poll/select Dave Penkler
2015-11-29 12:35 ` [PATCH v6 4/5] Add ioctl to retrieve USBTMC-USB488 capabilities Dave Penkler
2016-01-25 4:42 ` Greg KH
2016-01-26 18:15 ` Dave Penkler
2015-11-29 12:37 ` [PATCH v6 5/5] Add ioctls to enable and disable local controls on an instrument Dave Penkler
2016-01-25 4:47 ` Greg KH [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=20160125044748.GC14247@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=dpenkler@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@freescale.com \
--cc=teuniz@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).