should m_copyback possibly throw data away?

John-Mark Gurney jmg at funkthat.com
Fri Apr 24 18:12:01 UTC 2015


I was reviewing m_copyback from some other code, and noticed that it does
this:
        if (m0 == NULL)
                return;

at the beginin... If you pass in a NULL mbuf, it will not copy any data
in..  This is clearly to avoid panics, but at the same time, this means
we'll have data loss...  If someone tried to copy into a NULL mbuf,
it's likely a bug, and papering over that bug doesn't seem wise...

I'd like to see that removed (or changed to a KASSERT), but as it's been
in there since 1994:
https://svnweb.freebsd.org/base/head/sys/kern/uipc_mbuf.c?r1=3351&r2=3352

That's a pretty fundamental change...  mbuf(9) does not document this
behavior that data may be thrown away...

I would also be fine w/ documenting this behavior, though I'm sure
it'd be surprising to many that you'd have to check to make sure your
data was properly copied.

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-net mailing list