Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: Ensure non-equal id's are not same nhg's #16554

Merged

Conversation

donaldsharp
Copy link
Member

The function zebra_nhg_hash_equal is only used
as a hash function for storage of NHG's and retrieval. If you have say two nhg's:

31 (25/26)
32 (25/26)

This function would return them as being equal. Which of course leads to the problem when you attempt to hash_release 32 but release 31 from the hash. Then later when you attempt to do hash comparisons 32 has actually been freed leaving to use after free situations and shit goes down hill fast.

This hash is only used as part of the hash comparison function for nexthop group storage. Since this is so let's always return the 31/32 nhg's are not equal at all.

We possibly have a different problem where we are creating 31 and 32 ( when 31 should have just been used instead of 32 ) but we need to prevent any type of hash release problem at all. This supercedes any other issue( that should be tracked down on it's own ). Since you can have use after free situation that leads to a crash -vs- some possible nexthop group duplication which is very minor in comparison.

The function zebra_nhg_hash_equal is only used
as a hash function for storage of NHG's and retrieval.
If you have say two nhg's:

31 (25/26)
32 (25/26)

This function would return them as being equal.  Which
of course leads to the problem when you attempt to
hash_release 32 but release 31 from the hash.  Then later
when you attempt to do hash comparisons 32 has actually
been freed leaving to use after free situations and shit
goes down hill fast.

This hash is only used as part of the hash comparison
function for nexthop group storage.  Since this is so
let's always return the 31/32 nhg's are not equal at all.

We possibly have a different problem where we are creating
31 and 32 ( when 31 should have just been used instead of 32 )
but we need to prevent any type of hash release problem at all.
This supercedes any other issue( that should be tracked down
on it's own ).  Since you can have use after free situation
that leads to a crash -vs- some possible nexthop group duplication
which is very minor in comparison.

Signed-off-by: Donald Sharp <[email protected]>
@donaldsharp
Copy link
Member Author

this will fix an occasional crash that we are seeing in ospf_basic_functionality I believe

@ton31337
Copy link
Member

Valid failure?

E   AssertionError: Nexthop Group ID not found for sharpd route 6.6.6.1/32
   assert None is not None

@donaldsharp
Copy link
Member Author

I've been seeing that one off/on for the last couple of weeks. So no I do not believe it is

@ton31337 ton31337 merged commit 263eb6d into FRRouting:master Aug 12, 2024
14 checks passed
@ton31337
Copy link
Member

@Mergifyio backport stable/10.1 stable/10.0 stable/9.1 stable/9.0

Copy link

mergify bot commented Aug 12, 2024

backport stable/10.1 stable/10.0 stable/9.1 stable/9.0

✅ Backports have been created

donaldsharp added a commit that referenced this pull request Aug 13, 2024
zebra: Ensure non-equal id's are not same nhg's (backport #16554)
donaldsharp added a commit that referenced this pull request Aug 13, 2024
zebra: Ensure non-equal id's are not same nhg's (backport #16554)
donaldsharp added a commit that referenced this pull request Aug 13, 2024
zebra: Ensure non-equal id's are not same nhg's (backport #16554)
donaldsharp added a commit that referenced this pull request Aug 13, 2024
zebra: Ensure non-equal id's are not same nhg's (backport #16554)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants