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
F171084500: D58189.id.diff
Tue, Sep 8, 2:48 PM
Unknown Object (File)
Sat, Sep 5, 1:13 PM
Unknown Object (File)
Sat, Sep 5, 12:38 PM
Unknown Object (File)
Fri, Sep 4, 10:46 AM
Unknown Object (File)
Wed, Sep 2, 11:02 PM
Unknown Object (File)
Tue, Sep 1, 11:43 PM
Unknown Object (File)
Tue, Sep 1, 11:17 PM
Unknown Object (File)
Tue, Sep 1, 10:35 PM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 74743
Build 71626: arc lint + arc unit

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.