linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Todd Poynor <toddpoynor@gmail.com>
To: Rob Springer <rspringer@google.com>,
	John Joseph <jnjoseph@google.com>,
	Ben Chan <benchan@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Zhongze Hu <frankhu@chromium.org>, Simon Que <sque@chromium.org>,
	Dmitry Torokhov <dtor@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Todd Poynor <toddpoynor@google.com>
Subject: [PATCH 18/20] staging: gasket: apex ioctl add __user annotations
Date: Thu, 19 Jul 2018 20:49:18 -0700	[thread overview]
Message-ID: <20180720034920.77320-19-toddpoynor@gmail.com> (raw)
In-Reply-To: <20180720034920.77320-1-toddpoynor@gmail.com>

From: Todd Poynor <toddpoynor@google.com>

Add __user annotation to ioctl pointer argument, for sparse checking.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
---
 drivers/staging/gasket/apex_driver.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c
index 4c00f3609f081..3e76c4db5db2e 100644
--- a/drivers/staging/gasket/apex_driver.c
+++ b/drivers/staging/gasket/apex_driver.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2018 Google, Inc.
  */
 
+#include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/fs.h>
 #include <linux/init.h>
@@ -142,9 +143,10 @@ static int apex_get_status(struct gasket_dev *gasket_dev);
 
 static bool apex_ioctl_check_permissions(struct file *file, uint cmd);
 
-static long apex_ioctl(struct file *file, uint cmd, ulong arg);
+static long apex_ioctl(struct file *file, uint cmd, void __user *argp);
 
-static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg);
+static long apex_clock_gating(struct gasket_dev *gasket_dev,
+			      struct apex_gate_clock_ioctl __user *argp);
 
 static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type);
 
@@ -635,7 +637,7 @@ static bool apex_ioctl_check_permissions(struct file *filp, uint cmd)
 /*
  * Apex-specific ioctl handler.
  */
-static long apex_ioctl(struct file *filp, uint cmd, ulong arg)
+static long apex_ioctl(struct file *filp, uint cmd, void __user *argp)
 {
 	struct gasket_dev *gasket_dev = filp->private_data;
 
@@ -644,7 +646,7 @@ static long apex_ioctl(struct file *filp, uint cmd, ulong arg)
 
 	switch (cmd) {
 	case APEX_IOCTL_GATE_CLOCK:
-		return apex_clock_gating(gasket_dev, arg);
+		return apex_clock_gating(gasket_dev, argp);
 	default:
 		return -ENOTTY; /* unknown command */
 	}
@@ -653,16 +655,17 @@ static long apex_ioctl(struct file *filp, uint cmd, ulong arg)
 /*
  * Gates or un-gates Apex clock.
  * @gasket_dev: Gasket device pointer.
- * @arg: User ioctl arg, in this case to a apex_gate_clock_ioctl struct.
+ * @argp: User ioctl arg, pointer to a apex_gate_clock_ioctl struct.
  */
-static long apex_clock_gating(struct gasket_dev *gasket_dev, ulong arg)
+static long apex_clock_gating(struct gasket_dev *gasket_dev,
+			      struct apex_gate_clock_ioctl __user *argp)
 {
 	struct apex_gate_clock_ioctl ibuf;
 
 	if (bypass_top_level || !allow_sw_clock_gating)
 		return 0;
 
-	if (copy_from_user(&ibuf, (void __user *)arg, sizeof(ibuf)))
+	if (copy_from_user(&ibuf, argp, sizeof(ibuf)))
 		return -EFAULT;
 
 	gasket_log_error(gasket_dev, "%s %llu", __func__, ibuf.enable);
-- 
2.18.0.233.g985f88cf7e-goog


  parent reply	other threads:[~2018-07-20  3:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20  3:49 [PATCH 00/20 v4] staging: gasket: sundry fixes and fixups Todd Poynor
2018-07-20  3:49 ` [PATCH 01/20] staging: gasket: allow compile for ARM64 in Kconfig Todd Poynor
2018-07-20  3:49 ` [PATCH 02/20] staging: gasket: gasket_enable_dev remove unnecessary variable Todd Poynor
2018-07-21  6:48   ` Greg Kroah-Hartman
2018-07-20  3:49 ` [PATCH 03/20] staging: gasket: remove code for no physical device Todd Poynor
2018-07-20  3:49 ` [PATCH 04/20] staging: gasket: fix class create bug handling Todd Poynor
2018-07-20  3:49 ` [PATCH 05/20] staging: gasket: remove unnecessary code in coherent allocator Todd Poynor
2018-07-20  3:49 ` [PATCH 06/20] staging: gasket: don't treat no device reset callback as an error Todd Poynor
2018-07-20  3:49 ` [PATCH 07/20] staging: gasket: gasket_mmap return error instead of valid BAR index Todd Poynor
2018-07-20  3:49 ` [PATCH 08/20] staging: gasket: apex_clock_gating simplify logic, reduce indentation Todd Poynor
2018-07-20  3:49 ` [PATCH 09/20] staging: gasket: gasket page table functions use bool return type Todd Poynor
2018-07-20  3:49 ` [PATCH 10/20] staging: gasket: remove else clause after return in if clause Todd Poynor
2018-07-20  3:49 ` [PATCH 11/20] staging: gasket: fix comment syntax in apex.h Todd Poynor
2018-07-20  3:49 ` [PATCH 12/20] staging: gasket: remove unnecessary parens in page table code Todd Poynor
2018-07-20  3:49 ` [PATCH 13/20] staging: gasket: gasket_mmap use PAGE_MASK Todd Poynor
2018-07-20  3:49 ` [PATCH 14/20] staging: gasket: remove extra parens in gasket_write_mappable_regions Todd Poynor
2018-07-20  3:49 ` [PATCH 15/20] staging: gasket: fix multi-line comment syntax in gasket_core.h Todd Poynor
2018-07-20  3:49 ` [PATCH 16/20] staging: gasket: always allow root open for write Todd Poynor
2018-07-20  3:49 ` [PATCH 17/20] staging: gasket: top ioctl handler add __user annotations Todd Poynor
2018-07-20  3:49 ` Todd Poynor [this message]
2018-07-20  3:49 ` [PATCH 19/20] staging: gasket: common ioctl dispatcher " Todd Poynor
2018-07-20  3:49 ` [PATCH 20/20] staging: gasket: common ioctls " Todd Poynor
2018-07-21  6:51 ` [PATCH 00/20 v4] staging: gasket: sundry fixes and fixups Greg Kroah-Hartman
2018-07-21 12:56 [PATCH 00/14] staging: gasket: assorted cleanups Todd Poynor
2018-07-21 12:57 ` [PATCH 18/20] staging: gasket: apex ioctl add __user annotations Todd Poynor

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=20180720034920.77320-19-toddpoynor@gmail.com \
    --to=toddpoynor@gmail.com \
    --cc=benchan@chromium.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=dtor@chromium.org \
    --cc=frankhu@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=groeck@chromium.org \
    --cc=jnjoseph@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rspringer@google.com \
    --cc=sque@chromium.org \
    --cc=toddpoynor@google.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).