Re: adding 32 bit compatibility layer in custom kernel module

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

 



my app is crashing as it is trying iterate cmsghdrs
it got after call to recvmsg();
To give some context
below is the flow

32 bit app  <--> my kernel module <--> 64 bit app
my kernel module implements new protocol and 
provides 'struct proto_ops'
it never calls __sys_socket* calls.
once 32 bit app calls recvmsg(),
kernel module gets required data from another 64 bit app
via netlink msg.
issue here is the struct msghdr and strcu cmsgdr sizes
and members are of different lenghts.
so kernel module needs to give data to 32 bit app
in proper struct which are of correct sizes in 32 bit mode.
so kernel module needs a way to figure out
it is 32 bit app that made recvmsg() call and process accordingly.
i dont see compat_recv in struct proto_ops



On Wed, Jan 4, 2017 at 12:18 PM, Anish Kumar <anish198519851985@xxxxxxxxx> wrote:


On Jan 3, 2017, at 10:03 PM, Pradeepa Kumar <cdpradeepa@xxxxxxxxx> wrote:

Please see inline below

On Wed, Jan 4, 2017 at 11:07 AM, Anish Kumar <anish198519851985@xxxxxxxxx> wrote:


On Jan 3, 2017, at 8:04 PM, Pradeepa Kumar <cdpradeepa@xxxxxxxxx> wrote:

Hi experts

in my 64 bit kernel, I have a custom kernel module providing new protocol and providing socket system calls.

it works fine when 64 bit app runs.

i am seeing issues when 32 bit app runs (for exp recvmsg() call does not work if msg has cmsghdrs as struct size of cmsghdr is different in 32 bit and 64 bit).

This is because my custom kernel module does not have 32 bit compatibility layer ( but linux kernel has this in compat.c etc).

  • is it simple to add compatibility layer to my custom kernel module


    All you have to do is add compat_ioctl call to your driver.

my kernel module provides recvmsg() but i dont see any 'compat_recvmsg' in struct proto_ops.

Try to wrap your text in 80 characters.

Your application is crashing? Right?
Have you figured where it is crashing exactly?

I understood that your application is crashing as 
It not able to function with 64 bit kernel.

This happens because of the data being passed
to kernel is not in the right format. You need to
look at what you are passing to the driver and
if needed write the compat_ioctl callback in your
driver fops.
had there been  'compat_recvmsg' it would have been possible for me to define recvmsg() for 32 bit apps.
please let me know if i am missing anything

  • how do i do this (any links ?)


    You can see many drivers supports compat call.

Thanks

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxg
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux