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

isisd: fix rcap tlv double-free crash (backport #16809) #16845

Closed
wants to merge 2 commits into from

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Sep 17, 2024

Fix rcap tlv double-free crash. It is supposed to freed later by isis_free_tlvs() -> free_tlv_router_cap().

Fixes: 49efc80 ("isisd: Ensure rcap is freed in error case")


This is an automatic backport of pull request #16809 done by Mergify.

A double-free crash happens when a subTLV of the "Router Capability"
TLV is not readable and a previous "Router Capability" TLV was read.

rcap was supposed to be freed later by isis_free_tlvs() ->
free_tlv_router_cap(). In 78774bb ("isisd: add isis flex-algo lsp
advertisement"), this was not the case because rcap was not saved to
tlvs->router_cap when the function returned early because of a subTLV
length issue.

Always set tlvs->router_cap to free the memory.

Note that this patch has the consequence that in case of subTLV error,
the previously read "Router Capability" subTLVs are kept in memory.

Fixes: 49efc80 ("isisd: Ensure rcap is freed in error case")
Fixes: 78774bb ("isisd: add isis flex-algo lsp advertisement")
Reported-by: Iggy Frankovic <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
(cherry picked from commit d617581)
Since the previous commit, if a router capability subTLV is not
readable, the previously read subTLVs are kept.

Update of the ISIS fuzz test.

> $ wuschl rebuild tests/isisd/test_fuzz_isis_tlv
> $ gzip -9 tests/isisd/test_fuzz_isis_tlv_tests.h

> $ ./test_fuzz_isis_tlv 2>/dev/null | grep failed
> Test 139 failed, output differs.
> Test 150 failed, output differs.
> 2 of 405 tests failed.
>
> $ ./test_fuzz_isis_tlv 139 2>/dev/null
> Test 139 failed, output differs.
> Expected output:
> Unpack log:
> Unpacking 564 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 193 and len 13.
>     Skipping unknown TLV 193 (13 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Received output:
> Unpack log:
> Unpacking 564 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 193 and len 13.
>     Skipping unknown TLV 193 (13 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Router Capability: 253.212.128.242 , D:1, S:1
>
> $ ./test_fuzz_isis_tlv 150 2>/dev/null
> Test 150 failed, output differs.
> Expected output:
> Unpack log:
> Unpacking 403 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 129 and len 13.
>     Unpacking Protocols Supported TLV...
>       Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
>   Unpacking TLV...
>     Found TLV of type 11 and len 11.
>     Skipping unknown TLV 11 (11 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
> Received output:
> Unpack log:
> Unpacking 403 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 129 and len 13.
>     Unpacking Protocols Supported TLV...
>       Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
>   Unpacking TLV...
>     Found TLV of type 11 and len 11.
>     Skipping unknown TLV 11 (11 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
> Router Capability: 253.212.128.242 , D:1, S:1

Link: https://pypi.org/project/wuschl/
Signed-off-by: Louis Scalbert <[email protected]>
(cherry picked from commit cfd050a)

# Conflicts:
#	tests/isisd/test_fuzz_isis_tlv_tests.h.gz
@mergify mergify bot added the conflicts label Sep 17, 2024
Copy link
Author

mergify bot commented Sep 17, 2024

Cherry-pick of cfd050a has failed:

On branch mergify/bp/stable/9.0/pr-16809
Your branch is ahead of 'origin/stable/9.0' by 1 commit.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit cfd050a0e5.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   tests/isisd/test_fuzz_isis_tlv_tests.h.gz

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@frrbot frrbot bot added bugfix isis tests Topotests, make check, etc labels Sep 17, 2024
@ton31337 ton31337 closed this Sep 18, 2024
@ton31337 ton31337 deleted the mergify/bp/stable/9.0/pr-16809 branch September 18, 2024 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants