Page MenuHomeFreeBSD

netinet6/nd6: Sprinkle missing prefix refcounting
ClosedPublic

Authored by markj on Thu, Jul 23, 6:59 PM.
Tags
None
Referenced Files
F164363143: D58423.id182553.diff
Fri, Jul 31, 4:53 AM
F164298220: D58423.id.diff
Thu, Jul 30, 12:52 PM
Unknown Object (File)
Wed, Jul 29, 1:41 PM
Unknown Object (File)
Wed, Jul 29, 10:13 AM
Unknown Object (File)
Wed, Jul 29, 6:57 AM
Unknown Object (File)
Tue, Jul 28, 11:23 PM
Unknown Object (File)
Mon, Jul 27, 6:27 PM
Unknown Object (File)
Mon, Jul 27, 5:44 PM

Details

Summary

When we drop the prefix lock to call nd6_prefix_offlink() or
nd6_prefix_onlink(), make sure to keep the correpsonding prefix
structure alive. It is possible for a concurrent nd6_timer() to expire
the prefix while the lock is dropped.

Reported by: Maik Muench of Secfault Security

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75056
Build 71939: arc lint + arc unit

Event Timeline

markj requested review of this revision.Thu, Jul 23, 6:59 PM
sys/netinet6/nd6_rtr.c
1962–1963

shouldn't be after rlock?

2237–2238

same here

sys/netinet6/nd6_rtr.c
1962–1963

shouldn't be after rlock?

We don't call it after RLOCK. So it should be fine there.

2237–2238

same here

Maybe even after a_failure. Because we unlock it again and try to dereference it after.

sys/netinet6/nd6_rtr.c
1962–1963

There is no reason to acquire it after the read lock is reacquired.

2237–2238

I'm not sure what you are suggesting with a_failure.

Note, if the prefix was unlinked, then V_nd6_list_genid will be incremented. Conversely, if V_nd6_list_genid wasn't incremented, then the prefix must still be linked into the prefix list, so it's safe to use it to continue iterating.

sys/netinet6/nd6_rtr.c
2254

I'm talking about here.
If I understand it correctly:
Consider we unlock above again and we trying to dereference pr here.
So if timer runs right after above unlock and expire our pr, same thing could happen, right?
Or am I missing something?

sys/netinet6/nd6_rtr.c
2254

The caller of nd6_prefix_offlink() is expected to hold a ref on pr. With this patch, I think that's handled correctly.

This revision is now accepted and ready to land.Thu, Jul 23, 8:04 PM
zlei added a subscriber: zlei.

Looks good to me. @markj Do you plan to MFC ?

Looks good to me. @markj Do you plan to MFC ?

Certainly, yes.