Skip to content

Libcalico-go: Prevent segfault when network/ip is not valid#11084

Open
bartekzurawski wants to merge 1 commit intoprojectcalico:masterfrom
bartekzurawski:net_parsing
Open

Libcalico-go: Prevent segfault when network/ip is not valid#11084
bartekzurawski wants to merge 1 commit intoprojectcalico:masterfrom
bartekzurawski:net_parsing

Conversation

@bartekzurawski
Copy link
Contributor

Description

When a GlobalNetworkPolicy is created using the internal API group crd.projectcalico.org/v1, invalid CIDRs/IPs are not rejected. The conversion logic in libcalico-go then produces a nil *net.IPNet. Later, when Typha (or Felix) dereferences this pointer (e.g. in model.Rule.String()), a segfault occurs.

This PR changes:

  • Add nil check to avoid segfault
  • Make sure that processor code doesn't produce nil *net.IPNet

Normally users should not create objects via crd.projectcalico.org/v1, the supported API is projectcalico.org/v3, which performs proper validation. This change just makes the system more robust against unexpected nils.

Related issues/PRs

fixes #7697

Todos

  • Tests
  • Documentation
  • Release note

Release Note

TBD

Reminder for the reviewer

Make sure that this PR has the correct labels and milestone set.

Every PR needs one docs-* label.

  • docs-pr-required: This change requires a change to the documentation that has not been completed yet.
  • docs-completed: This change has all necessary documentation completed.
  • docs-not-required: This change has no user-facing impact and requires no docs.

Every PR needs one release-note-* label.

  • release-note-required: This PR has user-facing changes. Most PRs should have this label.
  • release-note-not-required: This PR has no user-facing changes.

Other optional labels:

  • cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.
  • needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.

@bartekzurawski bartekzurawski requested a review from a team as a code owner September 26, 2025 11:19
@marvin-tigera marvin-tigera added this to the Calico v3.32.0 milestone Sep 26, 2025
@marvin-tigera marvin-tigera added release-note-required Change has user-facing impact (no matter how small) docs-pr-required Change is not yet documented labels Sep 26, 2025
@mazdakn
Copy link
Member

mazdakn commented Oct 7, 2025

@bartekzurawski thanks for providing the fix. Can you also include a unit test for it?

@bartekzurawski
Copy link
Contributor Author

@mazdakn I've put some test for that change. Can you check?

@github-actions
Copy link

This PR is stale because it has been open for 60 days with no activity.

@github-actions github-actions bot added the stale Issues without recent activity label Jan 21, 2026
@fasaxc fasaxc added docs-not-required Docs not required for this change and removed docs-pr-required Change is not yet documented labels Jan 21, 2026
@github-actions github-actions bot removed the stale Issues without recent activity label Jan 21, 2026
@caseydavenport caseydavenport added the release-note-not-required Change has no user-facing impact label Jan 23, 2026
@marvin-tigera marvin-tigera removed the release-note-required Change has user-facing impact (no matter how small) label Jan 23, 2026
@caseydavenport
Copy link
Member

/sem-approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required Docs not required for this change release-note-not-required Change has no user-facing impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typha segfaults on invalid global network policies

5 participants

Comments