2007-12-22 04:56:23

by David Miller

[permalink] [raw]
Subject: [WEXT 8/12]: Pull top-level ioctl dispatch logic into helper function.


[WEXT]: Pull top-level ioctl dispatch logic into helper function.

Signed-off-by: David S. Miller <[email protected]>
---
net/wireless/wext.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/net/wireless/wext.c b/net/wireless/wext.c
index 18fa13c..03b0051 100644
--- a/net/wireless/wext.c
+++ b/net/wireless/wext.c
@@ -1111,8 +1111,10 @@ static int wext_permission_check(unsigned int cmd)
}

/* entry point from dev ioctl */
-int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
- void __user *arg)
+static int wext_ioctl_dispatch(struct net *net, struct ifreq *ifr,
+ unsigned int cmd,
+ wext_ioctl_func standard,
+ wext_ioctl_func private)
{
int ret = wext_permission_check(cmd);

@@ -1121,12 +1123,24 @@ int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,

dev_load(net, ifr->ifr_name);
rtnl_lock();
- ret = wireless_process_ioctl(net, ifr, cmd,
- ioctl_standard_call,
- ioctl_private_call);
+ ret = wireless_process_ioctl(net, ifr, cmd, standard, private);
rtnl_unlock();
- if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct iwreq)))
+
+ return ret;
+}
+
+int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
+ void __user *arg)
+{
+ int ret = wext_ioctl_dispatch(net, ifr, cmd,
+ ioctl_standard_call,
+ ioctl_private_call);
+
+ if (ret > 0 &&
+ IW_IS_GET(cmd) &&
+ copy_to_user(arg, ifr, sizeof(struct iwreq)))
return -EFAULT;
+
return ret;
}

--
1.5.4.rc1



2008-01-21 11:16:21

by Masakazu Mokuno

[permalink] [raw]
Subject: Re: [WEXT 8/12]: Pull top-level ioctl dispatch logic into helper function.

Hi Dave,

On Fri, 21 Dec 2007 20:56:23 -0800 (PST)
David Miller <[email protected]> wrote:

>
> [WEXT]: Pull top-level ioctl dispatch logic into helper function.
>
> Signed-off-by: David S. Miller <[email protected]>

<snip>

> +int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
> + void __user *arg)
> +{
> + int ret = wext_ioctl_dispatch(net, ifr, cmd,
> + ioctl_standard_call,
> + ioctl_private_call);
> +
> + if (ret > 0 &&

As the return value 0 is legal, should we allow copybacking in the case
of 'ret == 0'?

Same issue exists in compat_wext_handle_ioctl() of the #9 patch.

> + IW_IS_GET(cmd) &&
> + copy_to_user(arg, ifr, sizeof(struct iwreq)))
> return -EFAULT;
> +
> return ret;
> }


--
Masakazu MOKUNO


2008-06-03 14:34:57

by David Miller

[permalink] [raw]
Subject: Re: [WEXT 8/12]: Pull top-level ioctl dispatch logic into helper function.

From: Masakazu Mokuno <[email protected]>
Date: Mon, 21 Jan 2008 20:16:19 +0900

I am working on these patches again, thank you for your
extreme patience...

> > +int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
> > + void __user *arg)
> > +{
> > + int ret = wext_ioctl_dispatch(net, ifr, cmd,
> > + ioctl_standard_call,
> > + ioctl_private_call);
> > +
> > + if (ret > 0 &&
>
> As the return value 0 is legal, should we allow copybacking in the case
> of 'ret == 0'?
>
> Same issue exists in compat_wext_handle_ioctl() of the #9 patch.

You are right, I wonder why I made this strange test. It should
definitely be "ret >= 0". I'll make that fix.