Help needed with porting 32-bit user ioctl to run on a 64-bit kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All,

I am working on porting 32-bit application code to run over a 64-bit kernel.

The 32 bit code calls socket ioctl to programs some registers in the
driver (e1000) and then opens a raw socket.

The struct ifreq is used to construct the command as expected.

The problem i am facing is that, the data which is copied back into
the ioctl buffer is not visible in the user space at all.

[32-bit user space if req with command] ==> [IOCTL] ==> [64-bit
KERNEL] ==> [reads register copies result into ifreq->ifr_data in
kernel] ==> [The copied data is not visible in the user code].

Since the data i require is having a length of only 4 bytes,  i used
the ifr_data field itself as a buffer instead of using it as a pointer
to a buffer because i see that the ifreq structure is of 32 bytes
length and ifr_name is part of a union which has a size of 16 bytes.

I tried to do some debugging on this issue and found these:

the struct ifreq is 32 byte in 32-bit user space but is 40 bytes in
kernel space, this is probably because of the size of sockaddr inside
ifreq which is different for 64-bit, also copy_from/to_user is not
required because do_ioctl is already working on a copy of the ifreq
buffer.

I did some googling and found suggestions to use compat_ioctl to do
the porting, but that is pertaining to using the file_operations
structure, netdevice does not have a compat_ioctl, does it?

Any help is appreciated in this regard.

kind regards,
mz.
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Gstreamer Embedded]     [Linux MMC Devel]     [U-Boot V2]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux ARM Kernel]     [Linux OMAP]     [Linux SCSI]

  Powered by Linux