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

Fix agent panic in case of malformed objects retrieved from the kvstore, and improve validation #27237

Merged
merged 3 commits into from
Aug 7, 2023

Conversation

giorio94
Copy link
Member

@giorio94 giorio94 commented Aug 3, 2023

This PR adds extra validation to prevent processing invalid node and service objects retrieved from the kvstore, which could trigger unexpected behavior.

Fix agent panic in case malformed objects are retrieved from the kvstore, and improve validation

@giorio94 giorio94 added kind/bug This is a bug in the Cilium logic. release-note/bug This PR fixes an issue in a previous release of Cilium. area/clustermesh Relates to multi-cluster routing functionality in Cilium. sig/kvstore Impacts the KVStore package interactions. affects/v1.13 This issue affects v1.13 branch needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch labels Aug 3, 2023
@giorio94 giorio94 requested review from a team as code owners August 3, 2023 08:56
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from main in 1.14.1 Aug 3, 2023
@giorio94
Copy link
Member Author

giorio94 commented Aug 3, 2023

/test

Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀
I've left inline a non-blocking style improvement advice, feel free to do as you please.

Comment on lines +631 to +637
if n.ClusterID != option.Config.ClusterID {
if err := cmtypes.ValidateClusterID(n.ClusterID); err != nil {
return err
}
}

return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible style improvement:

Suggested change
if n.ClusterID != option.Config.ClusterID {
if err := cmtypes.ValidateClusterID(n.ClusterID); err != nil {
return err
}
}
return nil
if n.ClusterID == option.Config.ClusterID {
return nil
}
return cmtypes.ValidateClusterID(n.ClusterID)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking, I agree that your proposal is cleaner. I'd personally prefer to preserve the current approach, though, as it simplifies the addition of further checks, and it is consistent with the services validation.

@giorio94 giorio94 marked this pull request as draft August 3, 2023 13:12
Currently, the backends of global services received from remote clusters
are parsed using `MustParseAddrCluster`. Hence, a global service with
an invalid backend IP will cause the crash of all agents. Let's avoid
this using `ParseAddrCluster` and handling the error.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Add a validation function to prevent unmarshalling invalid
global service objects retrieved from the kvstore, which
could then possibly trigger unexpected behavior. Currently,
we check that the cluster ID is in the valid range, and
that IP addresses are valid.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Add a validation function to prevent unmarshalling invalid node
objects retrieved from the kvstore, which could then possibly
trigger unexpected behavior. Currently, we only check that the
cluster ID is in the valid range.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
@giorio94
Copy link
Member Author

giorio94 commented Aug 3, 2023

The last push reverted a minor modification for better consistency with the previous implementation, with no functional differences.

@giorio94
Copy link
Member Author

giorio94 commented Aug 3, 2023

/test

@giorio94 giorio94 marked this pull request as ready for review August 3, 2023 13:57
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Aug 7, 2023
@ldelossa ldelossa merged commit 23e762c into cilium:main Aug 7, 2023
59 checks passed
@joamaki joamaki mentioned this pull request Aug 8, 2023
9 tasks
@joamaki joamaki added backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. and removed needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch labels Aug 8, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from main to Backport pending to v1.14 in 1.14.1 Aug 8, 2023
@joamaki joamaki added backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. and removed backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. labels Aug 9, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.14 to Backport done to v1.14 in 1.14.1 Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/v1.13 This issue affects v1.13 branch area/clustermesh Relates to multi-cluster routing functionality in Cilium. backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. kind/bug This is a bug in the Cilium logic. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/kvstore Impacts the KVStore package interactions.
Projects
No open projects
1.14.1
Backport done to v1.14
Development

Successfully merging this pull request may close these issues.

None yet

6 participants