svn commit: r257535 - head/sys/netgraph

Bruce Evans brde at optusnet.com.au
Sat Nov 2 22:28:19 UTC 2013


On Sat, 2 Nov 2013, Mark R V Murray wrote:

> On 2 Nov 2013, at 09:32, Mark R V Murray <mark at grondar.org> wrote:
>>> Mark - did you initially mean the address of the mbuf m_data pointer,
>>> or the data payload itself?
>>
>> As Bruce says - the address of payload data itself. We don’t have 12-byte pointers in FreeBSD. :-)
>
> Cancel that.
>
> The address passed must be the address of the m_data field in the mbuf structure. The harvested data is 12 bytes from that address forward, so not the data pointed to by that m_data pointer but the pointer value itself and some following junk too.

Is that really worth using?  The mbuf data pointer is only slightly more
random than the mbuf pointer (equally non-random if the data is in the
mbuf).  The bytes following it are even less random.

I think the mbuf pointer usually points to an IP header.  12 bytes
gives everything except the source and destination addresses.  20 would
cover those too.  There can't be buffer overruns in practice, even with
a much larger size since small buffers go in the mbuf.

In the mbuf header starting at the data pointer, there are always 16
bytes in the header alone, and many more after the header.  On 32-bit
systems, the header has 2 more bytes in mh_type after the 12 followed
by 2 bytes of unnamed padding.  The padding might be random but is
more likely to be always 0.  16 altogether.  On 64-bit systems, the
header has 4 more bytes in mh_flags after the 12, then 2+2 for mh_type
and padding as above, then 4 more of unnamed padding.  24 altogether.

So why 12?

Bruce


More information about the svn-src-all mailing list