From: Arnd Bergmann <arnd@arndb.de>
To: linaro-mm-sig@lists.linaro.org
Cc: "Laura Abbott" <labbott@redhat.com>,
"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, 07 Sep 2016 21:37:53 +0200 [thread overview]
Message-ID: <3889942.OlqmzfXO6P@wuerfel> (raw)
In-Reply-To: <1473274199-30338-3-git-send-email-labbott@redhat.com>
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.
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.
Otherwise the patch looks good to me.
Arnd
next prev parent reply other threads:[~2016-09-07 19:37 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 ` Arnd Bergmann [this message]
2016-09-08 0:14 ` [Linaro-mm-sig] " Laura Abbott
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=3889942.OlqmzfXO6P@wuerfel \
--to=arnd@arndb.de \
--cc=Liviu.Dudau@arm.com \
--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=labbott@redhat.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
all inboxes | Powered by JetHome®