Page MenuHomeFreeBSD

mbuf_tags: use explicitly sized type for 'type' parameter
ClosedPublic

Authored by royger on Dec 28 2021, 8:56 AM.
Tags
None
Referenced Files
F122107238: D33680.id100646.diff
Wed, Jul 2, 8:23 AM
Unknown Object (File)
Tue, Jul 1, 6:06 PM
Unknown Object (File)
Tue, Jul 1, 8:52 AM
Unknown Object (File)
Wed, Jun 25, 5:00 PM
Unknown Object (File)
Mon, Jun 23, 9:05 PM
Unknown Object (File)
Mon, Jun 23, 10:23 AM
Unknown Object (File)
Sun, Jun 22, 1:29 AM
Unknown Object (File)
Sat, Jun 21, 11:44 PM
Subscribers

Details

Summary

Functions manipulating mbuf tags are using an int type for passing the
'type' parameter, but the internal tag storage is using a 16bit
integer to store it. This leads to the following code:

t = m_tag_alloc(...,0xffffffff,...,...);
m_tag_prepend(m, t);
r = m_tag_locate(m ,...,0xffffffff, NULL);

Returning r == NULL because m_tag_locate doesn't truncate the type
parameter when doing the match. This is unexpected because the type of
the 'type' parameter is int, and the caller doesn't need to know about
the internal truncations.

Fix this by making the 'type' parameter of type u_int16_t in order to
match the size of its internal storage and make it obvious to the
caller the actual size of the parameter.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 43626
Build 40514: arc lint + arc unit

Event Timeline

kp added a subscriber: kp.

Presumably you've done a make universe with this?

Sensible change anyway, we should avoid leaving landmines like that around where innocent people (or me!) could step on them.

share/man/man9/mbuf_tags.9
23

Don't forget to bump this when you commit.

sys/kern/uipc_mbuf2.c
317

We probably should try to be consistent about u_int vs. uint use.
Sadly the declaration in the header is already inconsistent with this. Perhaps that should be fixed at the same time as this.

Thanks! Will run the universe build if there are no further comments.

sys/kern/uipc_mbuf2.c
317

My preference would be to use uint, I don't mind fixing the lines I have to modify anyway if that's OK.

donner added a subscriber: donner.

Good catch

This revision is now accepted and ready to land.Dec 28 2021, 5:36 PM