pfil: Avoid potential mbuf tag leak

In '398254f9999e mbuf: simplify m_free' we removed tag processing
on m_free() of M_NOFREE mbufs. It is possible that a packet filter
could attach a tag to this stack mbuf and call m_free()
on it, meaning that 398254f9999e may have introduced a tag leak.

However,if a tag is attached without anyone calling m_free(), then
this leak was pre-existing.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D60686
Fixes: 398254f9999e
Sponsored by: Netflix

(cherry picked from commit f4ff995e361fa72cea240c4dbac2d0931965c80f)
This commit is contained in:
Andrew Gallatin 2026-10-13 09:01:26 -04:00 • committed by Franco Fichtner
parent 717cbf3f0d
commit 68b64bbc01

View file

@ -139,6 +139,8 @@ pfil_fake_mbuf(pfil_mbuf_chk_t func, void *mem, u_int len, struct ifnet *ifp,
*/
rv = PFIL_REALLOCED;
}
if (!SLIST_EMPTY(&m.m_pkthdr.tags))
m_tag_delete_chain(&m, NULL);
return (rv);
}