wext: Pull ioctl permission checking out into helper function.