Page MenuHomeFreeBSD

mbuf: make m_unshare() allow unmapped mbufs
ClosedPublic

Authored by takahiro.kurosawa_gmail.com on Jul 12 2026, 7:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 13, 6:29 AM
Unknown Object (File)
Thu, Aug 13, 1:45 AM
Unknown Object (File)
Tue, Aug 11, 10:54 PM
Unknown Object (File)
Mon, Aug 10, 9:49 AM
Unknown Object (File)
Mon, Aug 10, 9:46 AM
Unknown Object (File)
Mon, Aug 10, 9:41 AM
Unknown Object (File)
Mon, Aug 10, 7:46 AM
Unknown Object (File)
Sun, Aug 9, 10:51 AM
Subscribers

Details

Summary

m_unshare() had crashed if unmapped mbufs exist in the mbuf chain.
This was because memcpy() with mtod() was used without making sure that
the mbuf was mapped. Use m_copydata() that cares unmapped mbufs instead.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I'd write this as 'mcopydata(m,off, len, mtod(..));

Use m_copydata() instead of m_copyfromunmapped() as suggested by the review.

I'd write this as 'mcopydata(m,off, len, mtod(..));

I've updated the code and the summary text according to your comment.
It gets much simpler. Thanks for the review!

This revision is now accepted and ready to land.Jul 14 2026, 5:08 PM
This revision was automatically updated to reflect the committed changes.