[openib-general] Data structure size mismatch

Roland Dreier rolandd at cisco.com
Mon Nov 7 07:28:33 PST 2005


    Pradeep> Now, sizeof *packet will be different between 32-bit and
    Pradeep> 64-bit because of the pointers. Because of this, the
    Pradeep> offset of packet->mad will be incorrect and one might
    Pradeep> find unexpected data. Would you agree?

I don't understand your point.  packet is a kernel data structure, and
it doesn't matter that the layout changes if I compile the kernel for
a different architecture.  What is being copied from userspace is a
struct ib_user_mad whose does not depend on the word size.

Are you perhaps getting confused about the order of the parameters to
copy_from_user()?  They are ordered the same as memcpy(), that is the
destination is first, followed by the source.  So in

	if (copy_from_user(&packet->mad, buf,
			    sizeof (struct ib_user_mad) + IB_MGMT_RMPP_HDR)) {

the source of the data is the userspace pointer buf, and the exact
location of the destination packet->mad does not matter to userspace
at all -- it is purely kernel internal.

 - R.



More information about the general mailing list