Message ID | 20090810130359.p2hixk2eoow8kwg8@imap.linux.ibm.com |
---|---|
State | Rejected, archived |
Delegated to: | David Miller |
Headers | show |
cndougla@linux.vnet.ibm.com wrote: > PACKET_MMAP sets up a ring buffer at a memory location so that kernel > and user space can read from it without extra overhead. However, the > data is written with a header, struct tpacket_hdr, which begins with an > unsigned long field, tp_status. This means in a split 64-bit/32-bit > environment the kernel- and user-space reads from the mmap'd region will > be different, since in kernel-space the field is 64-bit while in > user-space the field is 32-bit. > > The following patch makes the size of the structure constant by changing > the tp_status field to 32-bits. It does not appear to need 64-bits, > since only 4-bits are actually used throughout the AF_PACKET code. > > Signed-off-by: Chase Douglas <cndougla@linux.vnet.ibm.com> > --- a/include/linux/if_packet.h 2009-08-10 16:53:11.000000000 +0000 > +++ b/include/linux/if_packet.h 2009-08-10 16:53:28.000000000 +0000 > @@ -65,7 +65,7 @@ struct tpacket_auxdata > > struct tpacket_hdr > { > - unsigned long tp_status; > + unsigned int tp_status; This changes the layout on 64 bit and thus breaks compatibility. The tpacket2_hdr doesn't suffer from this problem. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Aug 10, 2009, at 1:17 PM, Patrick McHardy wrote:
> The tpacket2_hdr doesn't suffer from this problem.
I hadn't noticed the new header version. I've grabbed the latest
version of libpcap which utilizes tpacket2_hdr where available, and
everything is fixed again.
Thanks
You can't make that change without breaking all existing 64-bit binaries running on 64-bit kernels. Secondarily, we're already fully aware of this problem, that's why there is a second version of the data structure named tpacket2_hdr which was created in a way which fixes the problem without breaking existing setups. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
--- a/include/linux/if_packet.h 2009-08-10 16:53:11.000000000 +0000 +++ b/include/linux/if_packet.h 2009-08-10 16:53:28.000000000 +0000 @@ -65,7 +65,7 @@ struct tpacket_auxdata struct tpacket_hdr { - unsigned long tp_status; + unsigned int tp_status; #define TP_STATUS_KERNEL 0 #define TP_STATUS_USER 1 #define TP_STATUS_COPY 2
PACKET_MMAP sets up a ring buffer at a memory location so that kernel and user space can read from it without extra overhead. However, the data is written with a header, struct tpacket_hdr, which begins with an unsigned long field, tp_status. This means in a split 64-bit/32-bit environment the kernel- and user-space reads from the mmap'd region will be different, since in kernel-space the field is 64-bit while in user-space the field is 32-bit. The following patch makes the size of the structure constant by changing the tp_status field to 32-bits. It does not appear to need 64-bits, since only 4-bits are actually used throughout the AF_PACKET code. Signed-off-by: Chase Douglas <cndougla@linux.vnet.ibm.com> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html