2016-06-02 15:17:43

by Dibyajyoti Ghosh

[permalink] [raw]
Subject: [PATCH] Support for 32 bit iwpriv on 64 bits kernels

This patch adds pointer conversion from 32 bit to 64 bit and vice versa,
if the ioctl is issued from 32 bit iwpriv to 64 bit Kernel.

Signed-off-by: Dibyajyoti Ghosh <[email protected]>
---
wireless_tools.29/iwpriv.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)

diff --git a/wireless_tools.29/iwpriv.c b/wireless_tools.29/iwpriv.c
index 4172fe2..a0b1b02 100644
--- a/wireless_tools.29/iwpriv.c
+++ b/wireless_tools.29/iwpriv.c
@@ -243,6 +243,7 @@ iw_usage(void)
fprintf(stderr, "Usage: iwpriv interface [private-command [private-arguments]]\n");
}

+#include<stdio.h>
/************************* SETTING ROUTINES **************************/

/*------------------------------------------------------------------*/
@@ -259,12 +260,20 @@ set_private_cmd(int skfd, /* Socket */
int priv_num) /* Number of descriptions */
{
struct iwreq wrq;
+ struct compat_iw_point {
+ __u64 pointer;
+ __u16 length;
+ __u16 flags;
+ };
u_char buffer[4096]; /* Only that big in v25 and later */
int i = 0; /* Start with first command arg */
int k; /* Index in private description table */
int temp;
int subcmd = 0; /* sub-ioctl index */
int offset = 0; /* Space for sub-ioctl index */
+ FILE *in;
+ char buff[4];
+ int kspace, uspace;

/* Check if we have a token index.
* Do it now so that sub-ioctl takes precedence, and so that we
@@ -457,6 +466,26 @@ set_private_cmd(int skfd, /* Socket */
}
}

+ in = popen("getconf LONG_BIT", "r");
+ fgets(buff, sizeof(buff), in);
+ pclose(in);
+ kspace = atoi(buff);
+ uspace = sizeof(char *) * 8;
+
+ struct compat_iw_point *iwp_compat = (struct compat_iw_point *)&wrq.u.data;
+ __u16 len = wrq.u.data.length;
+ __u16 flags = wrq.u.data.flags;
+
+ /* If 32 bit app is running on 64 bit kernel
+ * convert 32 bit iw_point type payload to 64 bit
+ */
+ if(uspace == 32 && kspace == 64)
+ {
+ iwp_compat->pointer = (__u64)((__u32)wrq.u.data.pointer);
+ iwp_compat->length = len;
+ iwp_compat->flags = flags;
+ }
+
/* Perform the private ioctl */
if(ioctl(skfd, priv[k].cmd, &wrq) < 0)
{
@@ -465,6 +494,18 @@ set_private_cmd(int skfd, /* Socket */
return(-1);
}

+ /* If 32 bit app is running on 64 bit kernel, convert the
+ * 64 bit result back to 32 bit to fit the app
+ */
+ if(uspace == 32 && kspace == 64)
+ {
+ flags = iwp_compat->flags;
+ len = iwp_compat->length;
+ wrq.u.data.pointer = (__u32)iwp_compat->pointer;
+ wrq.u.data.length = iwp_compat->length;
+ wrq.u.data.flags = iwp_compat->flags;
+ }
+
/* If we have to get some data */
if((priv[k].get_args & IW_PRIV_TYPE_MASK) &&
(priv[k].get_args & IW_PRIV_SIZE_MASK))
--
1.9.1



2016-06-02 15:36:47

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] Support for 32 bit iwpriv on 64 bits kernels

On Thu, 2016-06-02 at 20:51 +0530, Dibyajyoti Ghosh wrote:
> This patch adds pointer conversion from 32 bit to 64 bit and vice
> versa,
> if the ioctl is issued from 32 bit iwpriv to 64 bit Kernel.
>
Huh? the kernel should handle that, no? And didn't you just submit a
patch for it, so you break it again with this change?

johannes

2016-06-03 07:31:23

by Dibyajyoti Ghosh

[permalink] [raw]
Subject: Re: [PATCH] Support for 32 bit iwpriv on 64 bits kernels

Hi

Sorry for the conflict. We misunderstood from our kernel-patch related
conversation that it is you are reluctant to accept that. So we
attempted to accomplish the same through app-side modification. Any
way, sorry again.

However, we are again concentrating on our kernel side modification,
and will update you soon.

Thanks,
Dibyajyoti


On Thu, Jun 2, 2016 at 9:06 PM, Johannes Berg <[email protected]> wrote:
> On Thu, 2016-06-02 at 20:51 +0530, Dibyajyoti Ghosh wrote:
>> This patch adds pointer conversion from 32 bit to 64 bit and vice
>> versa,
>> if the ioctl is issued from 32 bit iwpriv to 64 bit Kernel.
>>
> Huh? the kernel should handle that, no? And didn't you just submit a
> patch for it, so you break it again with this change?
>
> johannes