lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1427406371-6699-1-git-send-email-mathieu.poirier@linaro.org>
Date:	Thu, 26 Mar 2015 15:46:11 -0600
From:	Mathieu Poirier <mathieu.poirier@...aro.org>
To:	alexander.shishkin@...ux.intel.com
Cc:	gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
	peter.lachner@...el.com, norbert.schulz@...el.com,
	keven.boell@...el.com, yann.fouassier@...el.com,
	laurent.fert@...el.com, linux-api@...r.kernel.org,
	kaixu.xia@...aro.org, zhang.chunyan@...aro.org,
	mathieu.poirier@...aro.org
Subject: [PATCH] stm class: Adding master and channel parameter to ioctl function

Hey Alex,

Have a look at the following patch and see if you agree with my approach.  If so
simply add the code to a third version. 

Thanks,
Mathieu

>From 70b4709b668ef59b303dabeff73ed850a4980cfc Mon Sep 17 00:00:00 2001
From: Mathieu Poirier <mathieu.poirier@...aro.org>
Date: Thu, 26 Mar 2015 15:33:03 -0600
Subject: [PATCH] stm class: Adding master and channel parameter to ioctl
 function

Just like the "write" function, architecture specific device need
to know about master and channels to do the correct operations on
a ioctl call.

Since this information is embedded in the stm_file structure that
is private to the stm class core, adding extra parameters to convey
the values is simple and clean.

Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
---
 drivers/hwtracing/stm/core.c | 12 ++++++++++--
 include/linux/stm.h          |  5 +++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 9e82634590dc..ca71b06bbfea 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -511,9 +511,17 @@ stm_char_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		return stm_char_policy_get_ioctl(stmf, (void __user *)arg);
 
 	default:
-		if (stm_data->ioctl)
-			err = stm_data->ioctl(stm_data, cmd, arg);
+		if (stm_data->ioctl) {
+			/* users shouldn't call device specific ioctl before
+			 * getting a channel using the proper potocol
+			 */
+			if (!stmf->output.nr_chans)
+				return -EINVAL;
 
+			err = stm_data->ioctl(stm_data, stmf->output.master,
+					      stmf->output.channel, cmd, arg);
+
+		}
 		break;
 	}
 
diff --git a/include/linux/stm.h b/include/linux/stm.h
index 976c94d8f17f..84dd83c47fe7 100644
--- a/include/linux/stm.h
+++ b/include/linux/stm.h
@@ -62,8 +62,9 @@ struct stm_data {
 					unsigned int);
 	void			(*unlink)(struct stm_data *, unsigned int,
 					  unsigned int);
-	long			(*ioctl)(struct stm_data *, unsigned int,
-					 unsigned long);
+	long			(*ioctl)(struct stm_data *,
+					 unsigned int, unsigned int,
+					 unsigned int, unsigned long);
 };
 
 int stm_register_device(struct device *parent, struct stm_data *stm_data,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ