[alsa-devel] [PATCH 06/27] ALSA: seq: obsolete change of address limit in in-kernel path for ioctl

Takashi Sakamoto o-takashi at sakamocchi.jp
Mon Aug 8 16:54:32 CEST 2016


In former commit, actual operations for each ioctl is re-designed to get
data in kernel space. Therefore, no need to cast pointer in kernel space
to user space.

This commit applies optimization to in-kernel path of ioctl.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 sound/core/seq/seq_clientmgr.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 586f9cd..449eb7a 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -2216,23 +2216,6 @@ static const struct seq_ioctl_table {
 	{ 0, NULL },
 };
 
-static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd,
-			    void __user *arg)
-{
-	const struct seq_ioctl_table *p;
-
-	if (! arg)
-		return -EFAULT;
-	for (p = ioctl_tables; p->cmd; p++) {
-		if (p->cmd == cmd)
-			return p->func(client, arg);
-	}
-	pr_debug("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n",
-		   cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
-	return -ENOTTY;
-}
-
-
 static long snd_seq_ioctl(struct file *file, unsigned int cmd,
 			  unsigned long arg)
 {
@@ -2484,16 +2467,23 @@ EXPORT_SYMBOL(snd_seq_kernel_client_dispatch);
 int snd_seq_kernel_client_ctl(int clientid, unsigned int cmd, void *arg)
 {
 	struct snd_seq_client *client;
-	mm_segment_t fs;
-	int result;
+	const struct seq_ioctl_table *p;
 
 	client = clientptr(clientid);
 	if (client == NULL)
 		return -ENXIO;
-	fs = snd_enter_user();
-	result = snd_seq_do_ioctl(client, cmd, (void __force __user *)arg);
-	snd_leave_user(fs);
-	return result;
+
+	for (p = ioctl_tables; p->cmd > 0; ++p) {
+		if (p->cmd == cmd)
+			break;
+	}
+	if (p->cmd == 0) {
+		pr_debug("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n",
+			 cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
+		return -ENOTTY;
+	}
+
+	return p->func(client, arg);
 }
 
 EXPORT_SYMBOL(snd_seq_kernel_client_ctl);
-- 
2.7.4



More information about the Alsa-devel mailing list