Segmentation Fault When using Netmap with big endian

sumith.devvojini at freescale.com sumith.devvojini at freescale.com
Tue Mar 3 21:28:54 UTC 2015


Hello Luigi,

I am a Software Engineer at Freescale semiconductor and I am currently working on porting netmap to Freescale's integrated network controller ETSEC. I came across the segmentation problem while testing my port with pkt-gen application provided as an example. This segmentation fault is due to the buffer pointer return to user space which is beyond the address space of the application. The reason for this I believe is line number 1351 in file netmap_mem2.c

                *(uint16_t *)(uintptr_t)&ring->nr_buf_size =
                        netmap_mem_bufsize(na->nm_mem);

where nr_buf_size is a 32 bit integer but we are storing the buffer size while casting this variable to a 16 bit integer pointer. When userspace application requests the buffer address we read this variable as a 32 bit integer and apply that as the offset.

Though this works on little endian systems because how they store the value in memory, it breaks in big endian systems. The cast can be changed to 32 bit integer pointer to make netmap more stable across different platforms.

Thank you,
Sumith Dev Vojini


More information about the freebsd-net mailing list