netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, viro@zeniv.linux.org.uk,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 18/19] atm: lift copyin from atm_dev_ioctl()
Date: Thu, 21 May 2020 01:37:20 +0100	[thread overview]
Message-ID: <20200521003721.3023783-18-viro@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200521003721.3023783-1-viro@ZenIV.linux.org.uk>

From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 net/atm/ioctl.c     | 25 ++++++++++++++++++++++++-
 net/atm/resources.c | 35 +++++------------------------------
 net/atm/resources.h |  4 ++--
 3 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c
index fdd0e3434523..52f2c77e656f 100644
--- a/net/atm/ioctl.c
+++ b/net/atm/ioctl.c
@@ -182,7 +182,30 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd,
 		}
 		error = atm_getnames(buf, len);
 	} else {
-		error = atm_dev_ioctl(cmd, argp, compat);
+		int number;
+
+		if (IS_ENABLED(CONFIG_COMPAT) && compat) {
+#ifdef CONFIG_COMPAT
+			struct compat_atmif_sioc __user *csioc = argp;
+			compat_uptr_t carg;
+
+			len = &csioc->length;
+			if (get_user(carg, &csioc->arg))
+				return -EFAULT;
+			buf = compat_ptr(carg);
+			if (get_user(number, &csioc->number))
+				return -EFAULT;
+#endif
+		} else {
+			struct atmif_sioc __user *sioc = argp;
+
+			len = &sioc->length;
+			if (get_user(buf, &sioc->arg))
+				return -EFAULT;
+			if (get_user(number, &sioc->number))
+				return -EFAULT;
+		}
+		error = atm_dev_ioctl(cmd, buf, len, number, compat);
 	}
 
 done:
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 5507cc608969..94bdc6527ee8 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -227,39 +227,14 @@ int atm_getnames(void __user *buf, int __user *iobuf_len)
 	return error;
 }
 
-int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat)
+int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
+		  int number, int compat)
 {
-	void __user *buf;
-	int error, len, number, size = 0;
+	int error, len, size = 0;
 	struct atm_dev *dev;
-	int __user *sioc_len;
 
-	if (IS_ENABLED(CONFIG_COMPAT) && compat) {
-#ifdef CONFIG_COMPAT
-		struct compat_atmif_sioc __user *csioc = arg;
-		compat_uptr_t carg;
-
-		sioc_len = &csioc->length;
-		if (get_user(carg, &csioc->arg))
-			return -EFAULT;
-		buf = compat_ptr(carg);
-
-		if (get_user(len, &csioc->length))
-			return -EFAULT;
-		if (get_user(number, &csioc->number))
-			return -EFAULT;
-#endif
-	} else {
-		struct atmif_sioc __user *sioc = arg;
-
-		sioc_len = &sioc->length;
-		if (get_user(buf, &sioc->arg))
-			return -EFAULT;
-		if (get_user(len, &sioc->length))
-			return -EFAULT;
-		if (get_user(number, &sioc->number))
-			return -EFAULT;
-	}
+	if (get_user(len, sioc_len))
+		return -EFAULT;
 
 	dev = try_then_request_module(atm_dev_lookup(number), "atm-device-%d",
 				      number);
diff --git a/net/atm/resources.h b/net/atm/resources.h
index 5e2c68d37d63..4a0839e92ff3 100644
--- a/net/atm/resources.h
+++ b/net/atm/resources.h
@@ -15,8 +15,8 @@ extern struct list_head atm_devs;
 extern struct mutex atm_dev_mutex;
 
 int atm_getnames(void __user *buf, int __user *iobuf_len);
-int atm_dev_ioctl(unsigned int cmd, void __user *arg, int compat);
-
+int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
+		  int number, int compat);
 
 #ifdef CONFIG_PROC_FS
 
-- 
2.11.0


  parent reply	other threads:[~2020-05-21  0:37 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11  4:43 [RFC][PATCHES] uaccess-related stuff in net/* Al Viro
2020-05-11  4:45 ` [PATCH 01/19] lift compat definitions of mcast [sg]etsockopt requests into net/compat.h Al Viro
2020-05-11  4:45   ` [PATCH 02/19] compat_ip{,v6}_setsockopt(): enumerate MCAST_... options explicitly Al Viro
2020-05-11  4:45   ` [PATCH 03/19] ip*_mc_gsfget(): lift copyout of struct group_filter into callers Al Viro
2020-05-11  4:45   ` [PATCH 04/19] get rid of compat_mc_getsockopt() Al Viro
2020-05-11  4:45   ` [PATCH 05/19] set_mcast_msfilter(): take the guts of setsockopt(MCAST_MSFILTER) into a helper Al Viro
2020-05-11  4:45   ` [PATCH 06/19] ipv4: do compat setsockopt for MCAST_MSFILTER directly Al Viro
2020-05-11  4:45   ` [PATCH 07/19] ip6_mc_msfilter(): pass the address list separately Al Viro
2020-05-11  4:45   ` [PATCH 08/19] ipv6: do compat setsockopt for MCAST_MSFILTER directly Al Viro
2020-05-11  4:45   ` [PATCH 09/19] ipv[46]: do compat setsockopt for MCAST_{JOIN,LEAVE}_GROUP directly Al Viro
2020-05-11  4:45   ` [PATCH 10/19] ipv4: take handling of group_source_req options into a helper Al Viro
2020-05-11  4:45   ` [PATCH 11/19] ipv6: " Al Viro
2020-05-11  4:45   ` [PATCH 12/19] handle the group_source_req options directly Al Viro
2020-05-11  4:45   ` [PATCH 13/19] get rid of compat_mc_setsockopt() Al Viro
2020-05-11  4:45   ` [PATCH 14/19] batadv_socket_read(): get rid of pointless access_ok() Al Viro
2020-05-11  4:45   ` [PATCH 15/19] atm: separate ATM_GETNAMES handling from the rest of atm_dev_ioctl() Al Viro
2020-05-11  4:45   ` [PATCH 16/19] atm: move copyin from atm_getnames() into the caller Al Viro
2020-05-11  4:45   ` [PATCH 17/19] atm: switch do_atm_iobuf() to direct use of atm_getnames() Al Viro
2020-05-11  4:45   ` [PATCH 18/19] atm: lift copyin from atm_dev_ioctl() Al Viro
2020-05-11  4:45   ` [PATCH 19/19] atm: switch do_atmif_sioc() to direct use of atm_dev_ioctl() Al Viro
2020-05-12  0:02 ` [RFC][PATCHES] uaccess-related stuff in net/* David Miller
2020-05-21  0:36   ` Al Viro
2020-05-21  0:37     ` [PATCH net-next 01/19] lift compat definitions of mcast [sg]etsockopt requests into net/compat.h Al Viro
2020-05-21  0:37       ` [PATCH net-next 02/19] compat_ip{,v6}_setsockopt(): enumerate MCAST_... options explicitly Al Viro
2020-05-21  0:37       ` [PATCH net-next 03/19] ip*_mc_gsfget(): lift copyout of struct group_filter into callers Al Viro
2020-05-21  0:37       ` [PATCH net-next 04/19] get rid of compat_mc_getsockopt() Al Viro
2020-05-21  0:37       ` [PATCH net-next 05/19] set_mcast_msfilter(): take the guts of setsockopt(MCAST_MSFILTER) into a helper Al Viro
2020-05-21  0:37       ` [PATCH net-next 06/19] ipv4: do compat setsockopt for MCAST_MSFILTER directly Al Viro
2020-05-21  0:37       ` [PATCH net-next 07/19] ip6_mc_msfilter(): pass the address list separately Al Viro
2020-05-21  0:37       ` [PATCH net-next 08/19] ipv6: do compat setsockopt for MCAST_MSFILTER directly Al Viro
2020-05-21  0:37       ` [PATCH net-next 09/19] ipv[46]: do compat setsockopt for MCAST_{JOIN,LEAVE}_GROUP directly Al Viro
2020-05-21  0:37       ` [PATCH net-next 10/19] ipv4: take handling of group_source_req options into a helper Al Viro
2020-05-21  0:37       ` [PATCH net-next 11/19] ipv6: " Al Viro
2020-05-21  0:37       ` [PATCH net-next 12/19] handle the group_source_req options directly Al Viro
2020-05-21  0:37       ` [PATCH net-next 13/19] get rid of compat_mc_setsockopt() Al Viro
2020-05-21  0:37       ` [PATCH net-next 14/19] batadv_socket_read(): get rid of pointless access_ok() Al Viro
2020-05-21  0:37       ` [PATCH net-next 15/19] atm: separate ATM_GETNAMES handling from the rest of atm_dev_ioctl() Al Viro
2020-05-21  0:37       ` [PATCH net-next 16/19] atm: move copyin from atm_getnames() into the caller Al Viro
2020-05-21  0:37       ` [PATCH net-next 17/19] atm: switch do_atm_iobuf() to direct use of atm_getnames() Al Viro
2020-05-21  0:37       ` Al Viro [this message]
2020-05-21  0:37       ` [PATCH net-next 19/19] atm: switch do_atmif_sioc() to direct use of atm_dev_ioctl() Al Viro
2020-05-21  2:24     ` [RFC][PATCHES] uaccess-related stuff in net/* David Miller

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=20200521003721.3023783-18-viro@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).