From 53f54339d769b63f1719c0fab6ca74be29350162 Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 19 Jul 2018 20:49:18 -0700 Subject: [PATCH] staging: gasket: apex ioctl add __user annotations Add __user annotation to ioctl pointer argument, for sparse checking. Change-Id: I677aa0a2eed9a34b799273e0a3a7cb45ced14c8e Reported-by: Dmitry Torokhov Signed-off-by: Zhongze Hu Signed-off-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- apex_driver.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/apex_driver.c b/apex_driver.c index c1cef70..c95071e 100644 --- a/apex_driver.c +++ b/apex_driver.c @@ -5,6 +5,7 @@ * Copyright (C) 2018 Google, Inc. */ +#include #include #include #include @@ -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 long apex_set_performance_expectation(struct gasket_dev *gasket_dev, ulong arg); @@ -637,7 +639,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; @@ -646,9 +648,9 @@ 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); case APEX_IOCTL_PERFORMANCE_EXPECTATION: - return apex_set_performance_expectation(gasket_dev, arg); + return apex_set_performance_expectation(gasket_dev, argp); default: return -ENOTTY; /* unknown command */ } @@ -657,16 +659,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);