Skip to content

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

Merged
joestringer merged 1 commit intomasterfrom
chaining
Jun 18, 2020
Merged

cilium: chaining mode skb->mark can be mangled by iptables allow opt-out#12185
joestringer merged 1 commit intomasterfrom
chaining

Conversation

@jrfastab
Copy link
Copy Markdown
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 [email protected]

@maintainer-s-little-helper
Copy link
Copy Markdown

Please set the appropriate release note label.

@jrfastab jrfastab requested review from aanm, joestringer 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
Copy Markdown
Contributor Author

test-me-please

@jrfastab
Copy link
Copy Markdown
Contributor Author

jrfastab commented Jun 18, 2020

fixes #12136

Copy link
Copy Markdown
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" -}}

Copy link
Copy Markdown
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 <[email protected]>
@jrfastab
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
cni-chaining-mode: {{ .Values.global.cni.chainingMode }}

{{- if hasKey .Values "enableIdentityMap"}}
enable-identity-map: {{ .Values.global.enableIdentityMap | quote }}
Copy link
Copy Markdown
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
Copy Markdown
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

julianwiedmann added a commit to julianwiedmann/cilium that referenced this pull request Apr 4, 2025
…ENTITY

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see cilium#12185).

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 4, 2025
When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 4, 2025
…ENTITY

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 4, 2025
When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 4, 2025
…ENTITY

[ upstream commit 2566ce2 ]

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 4, 2025
[ upstream commit c73b5f0 ]

When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 7, 2025
…ENTITY

[ upstream commit 2566ce2 ]

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 7, 2025
[ upstream commit c73b5f0 ]

When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 7, 2025
…ENTITY

[ upstream commit 2566ce2 ]

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 7, 2025
[ upstream commit c73b5f0 ]

When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 7, 2025
…ENTITY

[ upstream commit 2566ce2 ]

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 7, 2025
[ upstream commit c73b5f0 ]

When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 8, 2025
…ENTITY

[ upstream commit 2566ce2 ]

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 8, 2025
[ upstream commit c73b5f0 ]

When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 8, 2025
…ENTITY

[ upstream commit 2566ce2 ]

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Apr 8, 2025
[ upstream commit c73b5f0 ]

When AWS-CNI is in control of orchestrating the connectivity on the node,
we shouldn't assume that usage of skb->mark for Cilium is safe.

#12185 introduced the
`--enable-identity-mark` option for this scenario, so that Cilium doesn't
use the skb->mark for identity propagation. Set this flag in the AWS-CNI
workflow accordingly.

Signed-off-by: Julian Wiedmann <[email protected]>
julianwiedmann added a commit that referenced this pull request Apr 9, 2025
…ENTITY

[ upstream commit 2566ce2 ]

For environments where option.EnableIdentityMark is not set (and thus
from-container doesn't set the source identity in the skb->mark), we
shouldn't attempt to retrieve the identity.

Which leaves the question whether all the *other* use of skb->mark in this
program is safe. Or all those features are simply incompatible with
running in a CNI-chained environment, where skb->mark is not owned by
Cilium (see #12185).

Signed-off-by: Julian Wiedmann <[email protected]>
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

None yet

Development

Successfully merging this pull request may close these issues.

7 participants