From: Laura Abbott <labbott@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>, linaro-mm-sig@lists.linaro.org
Cc: "Sumit Semwal" <sumit.semwal@linaro.org>,
"John Stultz" <john.stultz@linaro.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Riley Andrews" <riandrews@android.com>,
"Brian Starkey" <brian.starkey@arm.com>,
devel@driverdev.osuosl.org, "Jon Medhurst" <tixy@linaro.org>,
"Android Kernel Team" <kernel-team@android.com>,
"Liviu Dudau" <Liviu.Dudau@arm.com>,
linux-kernel@vger.kernel.org,
"Jeremy Gebben" <jgebben@codeaurora.org>,
"Eun Taik Lee" <eun.taik.lee@samsung.com>,
"Chen Feng" <puck.chen@hisilicon.com>
Subject: Re: [Linaro-mm-sig] [PATCHv3 2/2] staging: android: ion: Add ioctl to query available heaps
Date: Wed, 7 Sep 2016 17:14:48 -0700 [thread overview]
Message-ID: <123eb3c5-ecec-4b05-d541-832086e9c670@redhat.com> (raw)
In-Reply-To: <3889942.OlqmzfXO6P@wuerfel>
On 09/07/2016 12:37 PM, Arnd Bergmann wrote:
> On Wednesday, September 7, 2016 11:49:59 AM CEST Laura Abbott wrote:
>
>> - if (dir & _IOC_WRITE)
>> - if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd)))
>> - return -EFAULT;
>> + /*
>> + * The copy_from_user is unconditional here for both read and write
>> + * to do the validate. If there is no write for the ioctl, the
>> + * buffer is cleared
>> + */
>> + if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd)))
>> + return -EFAULT;
>> +
>> + ret = validate_ioctl_arg(cmd, &data);
>> + if (WARN_ON_ONCE(ret))
>> + return ret;
>
> I noticed that the WARN_ON_ONCE warns about invalid user input,
> but I think we tend to normally just use WARN_ON for things that
> go wrong inside of the kernel or in hardware.
>
> Maybe better use printk_once() or printk_ratelimited.
>
Sure, the error code should hopefully be enough of a hint to
userspace to maybe check the log.
> Is there any noticeable overhead in always copying the structure?
> copy_from_user() can be a bit slow depending on debugging or
> security features, and it seems unnecessary if the validation
> is only done for one of the commands.
>
Good point. It made sense with some of the other ioctls (specifically
the ABI) but isn't necessary now. We can evaluate later when other
ioctls get added.
> Otherwise the patch looks good to me.
>
> Arnd
>
Thanks!
Laura
prev parent reply other threads:[~2016-09-08 0:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-07 18:49 [PATCHv3 0/2] New Ion query ioctl Laura Abbott
2016-09-07 18:49 ` [PATCHv3 1/2] staging: android: ion: Pull out ion ioctls to a separate file Laura Abbott
2016-09-07 19:38 ` [Linaro-mm-sig] " Arnd Bergmann
2016-09-07 18:49 ` [PATCHv3 2/2] staging: android: ion: Add ioctl to query available heaps Laura Abbott
2016-09-07 19:37 ` [Linaro-mm-sig] " Arnd Bergmann
2016-09-08 0:14 ` Laura Abbott [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=123eb3c5-ecec-4b05-d541-832086e9c670@redhat.com \
--to=labbott@redhat.com \
--cc=Liviu.Dudau@arm.com \
--cc=arnd@arndb.de \
--cc=arve@android.com \
--cc=brian.starkey@arm.com \
--cc=devel@driverdev.osuosl.org \
--cc=eun.taik.lee@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=jgebben@codeaurora.org \
--cc=john.stultz@linaro.org \
--cc=kernel-team@android.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=puck.chen@hisilicon.com \
--cc=riandrews@android.com \
--cc=sumit.semwal@linaro.org \
--cc=tixy@linaro.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
Powered by JetHome