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

cilium: chaining mode skb->mark can be mangled by iptables allow opt-out #12185

Merged
merged 1 commit into from Jun 18, 2020

Conversation

jrfastab
Copy link
Contributor

The skb->mark field may not reliable in chaining modes because the host
stack may have conflicting users of the mark field. For example in one
case we observe a set mark rule 'MARK and 0xfff1ffff' which mangles the
identity stored in skb->mark. If Cilium user also has ingress policy
logic the identity is no longer correct. This likely will result in policy
denied hits,

-> stack flow 0xa0688256 identity 54898->7179 state established ifindex 0 orig-ip 0.0.0.0: 192.168.187.136:50344 -> 192.168.187.139:80 tcp SYN
xx drop (Policy denied) flow 0xa0688256 to endpoint 149, identity 54897->7179: 192.168.187.136:50344 -> 192.168.187.139:80 tcp SYN

To fix this create a flag EnableIdentityMark to allow setting the identity.
In cases that have conflicting mark values this can then be disabled. The
trace on ingress will no longer have a listed identity but because when
'identity < UNMANAGED' we do the lookup using the src ip and policy will
work correctly.

Fixes: f25d8b9 ("bpf: Preserve source identity for hairpin via stack")
Signed-off-by: John Fastabend john.fastabend@gmail.com

@maintainer-s-little-helper
Copy link

Please set the appropriate release note label.

@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.8.0 Jun 18, 2020
@jrfastab jrfastab requested review from joestringer, aanm and tgraf and removed request for joestringer June 18, 2020 16:28
@jrfastab jrfastab marked this pull request as ready for review June 18, 2020 17:25
@jrfastab jrfastab requested review from a team June 18, 2020 17:25
@jrfastab jrfastab requested review from a team as code owners June 18, 2020 17:25
@jrfastab jrfastab requested a review from a team June 18, 2020 17:25
@jrfastab
Copy link
Contributor Author

test-me-please

@jrfastab
Copy link
Contributor Author

jrfastab commented Jun 18, 2020

fixes #12136

@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.8.0 Jun 18, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.7.6 Jun 18, 2020
@@ -307,6 +307,8 @@ data:
# - portmap (Enables HostPort support for Cilium)
cni-chaining-mode: {{ .Values.global.cni.chainingMode }}

enable-identity-map: {{ .Values.global.enableIdentityMap }}
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be:

{{- if hasKey .Values "enableIdentityMap" }}
  enable-identity-map: {{ .Values.enableIdentityMap | quote }}
{{- else if (ne $enableIdentityMap "true") }}
  enable-identity-map: "false"
{{- end }}

and on top of this file:

...
{{- /* Default values when 1.8 was initially deployed */ -}}
...
{{- $enableIdentityMap = "true" -}}

@@ -186,6 +186,8 @@ global:
endpointRoutes:
enabled: false

enableIdentityMark: true
Copy link
Member

Choose a reason for hiding this comment

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

this should be in the cilium/charts/config/values.yaml like the other flags are

The skb->mark field may not reliable in chaining modes because the host
stack may have conflicting users of the mark field. For example in one
case we observe a set mark rule 'MARK and 0xfff1ffff' which mangles the
identity stored in skb->mark. If Cilium user also has ingress policy
logic the identity is no longer correct. This likely will result in policy
denied hits,

-> stack flow 0xa0688256 identity 54898->7179 state established ifindex 0 orig-ip 0.0.0.0: 192.168.187.136:50344 -> 192.168.187.139:80 tcp SYN
xx drop (Policy denied) flow 0xa0688256 to endpoint 149, identity 54897->7179: 192.168.187.136:50344 -> 192.168.187.139:80 tcp SYN

To fix this create a flag EnableIdentityMark to allow setting the identity.
In cases that have conflicting mark values this can then be disabled. The
trace on ingress will no longer have a listed identity but because when
'identity < UNMANAGED' we do the lookup using the src ip and policy will
work correctly.

Fixes: f25d8b9 ("bpf: Preserve source identity for hairpin via stack")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
@jrfastab
Copy link
Contributor Author

test-me-please

Comment on lines +50 to +52
# enables passing identity on local routes by using the mark fields. However,
# in cases where this conflicts with a chained CNI plugin it may be disabled.
#enableIdentityMark: true
Copy link
Member

Choose a reason for hiding this comment

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

I don't see the corresponding chaining docs changes for this, did you intend to add them here?

Copy link
Member

Choose a reason for hiding this comment

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

We should set it in the Calico guide

Comment on lines +353 to +357
{{- if hasKey .Values "enableIdentityMap"}}
enable-identity-map: {{ .Values.global.enableIdentityMap | quote }}
{{- else if (ne $enableIdentityMap "true") }}
enable-identity-map: "false"
{{- end }}
Copy link
Member

Choose a reason for hiding this comment

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

@tgraf has the freshest understanding of exactly how to format these options, would be good to get a quick look from him whether it's actually matching our latest approach.

@joestringer joestringer added the release-note/bug This PR fixes an issue in a previous release of Cilium. label Jun 18, 2020
Comment on lines +50 to +52
# enables passing identity on local routes by using the mark fields. However,
# in cases where this conflicts with a chained CNI plugin it may be disabled.
#enableIdentityMark: true
Copy link
Member

Choose a reason for hiding this comment

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

We should set it in the Calico guide

@joestringer joestringer added the priority/high This is considered vital to an upcoming release. label Jun 18, 2020
@joestringer
Copy link
Member

Just docs fixes remaining, those can be handled in a follow-up PR.

@joestringer joestringer merged commit 1cc79c1 into master Jun 18, 2020
1.8.0 automation moved this from In progress to Merged Jun 18, 2020
@joestringer joestringer deleted the chaining branch June 18, 2020 23:03
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.8 in 1.8.0 Jun 19, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.8 to Backport done to v1.8 in 1.8.0 Jun 19, 2020
@aanm aanm removed this from Needs backport from master in 1.7.6 Jul 3, 2020
@aanm aanm added this to Needs backport from master in 1.7.7 Jul 3, 2020
@@ -349,6 +350,12 @@ data:
# - portmap (Enables HostPort support for Cilium)
cni-chaining-mode: {{ .Values.global.cni.chainingMode }}

{{- if hasKey .Values "enableIdentityMap"}}
enable-identity-map: {{ .Values.global.enableIdentityMap | quote }}
Copy link
Member

@vadorovsky vadorovsky Jul 8, 2020

Choose a reason for hiding this comment

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

Don't we have a mismatch here? The new argument in the daemon is enable-identity-mark, but here we define enable-identity-map. Shouldn't we do s/map/mark/ in helm charts?

Am I missing something here?

I noticed that when backporting to 1.7.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, it got fixed here #12194

@joestringer joestringer moved this from Needs backport from master to Backport pending to v1.7 in 1.7.7 Jul 9, 2020
@joestringer joestringer moved this from Backport pending to v1.7 to Backport done to v1.7 in 1.7.7 Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/high This is considered vital to an upcoming release. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
No open projects
1.7.7
Backport done to v1.7
1.8.0
  
Merged
1.8.0
Backport done to v1.8
Development

Successfully merging this pull request may close these issues.

None yet

7 participants