Re: Allocate userspace memory

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

 



On Saturday 05 May 2007 10:32, Jirka Pirko wrote:

> > Or use configfs/sysfs, passing structures in and out of the kernel is
> > not recommended for a large number of very good reasons (not the least
> > being 32/64bit reasons).
>
> please tell me this reasons
>

If you are running a 64bit kernel and 32bit userspace, and you are using 
pointers and longs in some structure that you need to pass between kernel and 
user, that structure will have different layouts in the two realms.

(because long and pointers are 64bits on 64bit ABI while on 32bit ABI they are 
32bits)

For example, the following structure:

struct {
	long a;
	char b;
}

will have the following layout on 32bit (userspace):

a a a a b (big endian)

while on 64bit (kernel) will look like:

a a a a a a a a  b 


Because of that you will need to convert the received structure from userspace 
to a structure that the kernel can use. It can get very ugly for complex 
structures.

regards,
tavi






--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[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