Commit 0a06ea87185531705e4417e3a051f81b64f210c1

Authored by David S. Miller
1 parent a572da4373

[WIRELESS] WEXT: Fix userspace corruption on 64-bit.

On 64-bit systems sizeof(struct ifreq) is 8 bytes larger than
sizeof(struct iwreq).

For GET calls, the wireless extension code copies back into userspace
using sizeof(struct ifreq) but userspace and elsewhere only allocates
a "struct iwreq".  Thus, this copy writes past the end of the iwreq
object and corrupts whatever sits after it in memory.

Fix the copy_to_user() length.

This particularly hurts the compat case because the wireless compat
code uses compat_alloc_userspace() and right after this allocated
buffer is the current bottom of the user stack, and that's what gets
overwritten by the copy_to_user() call.

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -1094,7 +1094,7 @@
1094 1094 rtnl_lock();
1095 1095 ret = wireless_process_ioctl(net, ifr, cmd);
1096 1096 rtnl_unlock();
1097   - if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq)))
  1097 + if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct iwreq)))
1098 1098 return -EFAULT;
1099 1099 return ret;
1100 1100 }