aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-12-21 06:36:31 -0500
committerDavid S. Miller <davem@davemloft.net>2008-06-16 21:30:47 -0400
commit67dd7608078b17f63f29ff2108fc5bf2407ddcec (patch)
tree92dda0580609f2be16c45e9c8bdbaed0d1fb5a00
parentd88174e4d295f0880e5f9cb6d42f26b0367c8fd9 (diff)
wext: Pull ioctl permission checking out into helper function.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/wireless/wext.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/net/wireless/wext.c b/net/wireless/wext.c
index a1cd19add6d8..e96559ea0fb3 100644
--- a/net/wireless/wext.c
+++ b/net/wireless/wext.c
@@ -1061,18 +1061,26 @@ static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, unsigned i
1061 return -EOPNOTSUPP; 1061 return -EOPNOTSUPP;
1062} 1062}
1063 1063
1064/* If command is `set a parameter', or `get the encoding parameters',
1065 * check if the user has the right to do it.
1066 */
1067static int wext_permission_check(unsigned int cmd)
1068{
1069 if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
1070 && !capable(CAP_NET_ADMIN))
1071 return -EPERM;
1072
1073 return 0;
1074}
1075
1064/* entry point from dev ioctl */ 1076/* entry point from dev ioctl */
1065int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd, 1077int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
1066 void __user *arg) 1078 void __user *arg)
1067{ 1079{
1068 int ret; 1080 int ret = wext_permission_check(cmd);
1069 1081
1070 /* If command is `set a parameter', or 1082 if (ret)
1071 * `get the encoding parameters', check if 1083 return ret;
1072 * the user has the right to do it */
1073 if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
1074 && !capable(CAP_NET_ADMIN))
1075 return -EPERM;
1076 1084
1077 dev_load(net, ifr->ifr_name); 1085 dev_load(net, ifr->ifr_name);
1078 rtnl_lock(); 1086 rtnl_lock();