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

DATA RACE in pkg/endpoint.(*Endpoint).GetIdentity() #11932

Closed
aanm opened this issue Jun 5, 2020 · 5 comments
Closed

DATA RACE in pkg/endpoint.(*Endpoint).GetIdentity() #11932

aanm opened this issue Jun 5, 2020 · 5 comments
Assignees
Labels
kind/bug This is a bug in the Cilium logic.

Comments

@aanm
Copy link
Member

aanm commented Jun 5, 2020

Jun 05 14:44:34 runtime cilium-agent[31884]: WARNING: DATA RACE
Jun 05 14:44:34 runtime cilium-agent[31884]: Read at 0x00c003df24b8 by goroutine 180:
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).GetIdentity()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/endpoint/endpoint.go:613 +0x4a
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/hubble/parser/threefour.(*Parser).resolveEndpoint()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/hubble/parser/threefour/parser.go:252 +0x7db
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/hubble/parser/threefour.(*Parser).Decode()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/hubble/parser/threefour/parser.go:154 +0x723
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/hubble/parser.(*Parser).Decode()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/hubble/parser/new.go:73 +0xbd
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/hubble/observer.decodeFlow()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/hubble/observer/local_observer.go:340 +0xa8
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/hubble/observer.(*LocalObserverServer).Start()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/hubble/observer/local_observer.go:156 +0x1c2
Jun 05 14:44:34 runtime cilium-agent[31884]: Previous write at 0x00c003df24b8 by goroutine 138:
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).SetIdentity()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/endpoint/policy.go:733 +0x237
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/identity/identitymanager.RemoveOldAddNew()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/identity/identitymanager/manager.go:134 +0xa05
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).SetIdentity()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/endpoint/policy.go:731 +0x9aa
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).identityLabelsChanged()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/endpoint/endpoint.go:1870 +0xae6
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).runIdentityResolver()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/endpoint/endpoint.go:1727 +0x4bd
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/endpoint.(*Endpoint).UpdateLabels()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/endpoint/endpoint.go:1688 +0x467
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/cilium-health/launch.LaunchAsEndpoint()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/cilium-health/launch/endpoint.go:368 +0x15a4
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.(*Daemon).initHealth.func1()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/health.go:85 +0x2ac
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Controller).runController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xc71
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Controller).runController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xc71
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Controller).runController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xc71
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Controller).runController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xc71
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Controller).runController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xc71
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Controller).runController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xc71
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Controller).runController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/controller.go:205 +0xc71
Jun 05 14:44:34 runtime cilium-agent[31884]: Goroutine 180 (running) created at:
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.(*Daemon).launchHubble()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/hubble.go:118 +0x7bb
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.runDaemon()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:1425 +0x1410
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.NewDaemon()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon.go:502 +0x2c42
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.runDaemon()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:1281 +0x354
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.glob..func1()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:116 +0xab
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/spf13/cobra.(*Command).execute()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/vendor/github.com/spf13/cobra/command.go:846 +0x8e0
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/spf13/cobra.(*Command).ExecuteC()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/vendor/github.com/spf13/cobra/command.go:950 +0x499
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/spf13/cobra.(*Command).Execute()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/vendor/github.com/spf13/cobra/command.go:887 +0x1eb
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.Execute()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:147 +0x1cc
Jun 05 14:44:34 runtime cilium-agent[31884]:   main.main()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/main.go:22 +0x2f
Jun 05 14:44:34 runtime cilium-agent[31884]: Goroutine 138 (running) created at:
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Manager).updateController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/manager.go:120 +0xfbc
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/pkg/controller.(*Manager).UpdateController()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/pkg/controller/manager.go:59 +0x6bf
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.(*Daemon).initHealth()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/health.go:71 +0x46b
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.runDaemon()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:1367 +0x2356
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.NewDaemon()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon.go:502 +0x2c42
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.runDaemon()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:1281 +0x354
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.glob..func1()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:116 +0xab
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/spf13/cobra.(*Command).execute()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/vendor/github.com/spf13/cobra/command.go:846 +0x8e0
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/spf13/cobra.(*Command).ExecuteC()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/vendor/github.com/spf13/cobra/command.go:950 +0x499
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/spf13/cobra.(*Command).Execute()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/vendor/github.com/spf13/cobra/command.go:887 +0x1eb
Jun 05 14:44:34 runtime cilium-agent[31884]:   github.com/cilium/cilium/daemon/cmd.Execute()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/cmd/daemon_main.go:147 +0x1cc
Jun 05 14:44:34 runtime cilium-agent[31884]:   main.main()
Jun 05 14:44:34 runtime cilium-agent[31884]:       /home/vagrant/go/src/github.com/cilium/cilium/daemon/main.go:22 +0x2f

Needs triage to assess how serious the bug is because to me it looks like endpoint.SecurityIdentity is not as protected as it should be.

@aanm aanm added kind/bug This is a bug in the Cilium logic. priority/release-blocker needs/triage This issue requires triaging to establish severity and next steps. sig/hubble Impacts hubble server or relay labels Jun 5, 2020
@glibsm
Copy link
Member

glibsm commented Jun 5, 2020

where did you see this race, CI run or locally?

@aanm
Copy link
Member Author

aanm commented Jun 5, 2020

where did you see this race, CI run or locally?

CI run

@glibsm
Copy link
Member

glibsm commented Jun 5, 2020

The bug itself is not serious, it can result in old/new value being assigned to a flow as endpoint is changing the id. There isn't much that can be done about this, as flows are constantly decoded

It could definitely create weird situations where endpoint struct is mid-update, and we read some old and some new values.

For fixing the race, it does look like there is a missing protection for get/set identity.

@glibsm
Copy link
Member

glibsm commented Jun 5, 2020

I think Simply protecting endpoint.SecurityIdentity would probably eliminate the DATA race, but would actually be subject to data inconsistency issues

A more functional way to fix this is to make sure all necessary values are read right away in

if ep, ok := p.endpointGetter.GetEndpointInfo(ip); ok {

Otherwise it's a pointer and sub-sequent calls can be racy

@tgraf tgraf self-assigned this Jun 7, 2020
@tgraf tgraf removed the sig/hubble Impacts hubble server or relay label Jun 7, 2020
@tgraf
Copy link
Member

tgraf commented Jun 7, 2020

There are several places which are vulnerable, this is not Hubble specific:

  • daemon/cmd/fqdn.go / notifyOnDNSMsg():

    LookupEndpointIDByIP(). No locking.

    --> Vulnerable

  • pkg/datapath/linux/config/config.go / writeStaticData()

    e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

    The endpoint is locked

    --> Not vulnerable

  • pkg/datapath/loader/template.go

    e.realizeBPFState() ->
    -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
    -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
    -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

    Uses epInfoCache --> Not vulnerable

  • pkg/envoy/server.go

    e.updateNetworkPolicy() -> UpdateNetworkPolicy()

    The endpoint is locked

    --> Not vulnerable

  • pkg/hubble/parser/threefour/parser.go

    Decode() -> resolveEndpoint()

    --> Vulnerable

@tgraf tgraf removed the needs/triage This issue requires triaging to establish severity and next steps. label Jun 7, 2020
tgraf added a commit that referenced this issue Jun 7, 2020
Calls to GetIdentity() have been assuming both that the endpoint is
locked or not locked.

* daemon/cmd/fqdn.go / notifyOnDNSMsg():

  LookupEndpointIDByIP(). No locking.

  --> Vulnerable

* pkg/datapath/linux/config/config.go / writeStaticData()

  e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

  The endpoint is locked. Not using epCacheInfo. Must use a non-locking
  variation or a deadlock may occur.

  --> Not vulnerable

* pkg/datapath/loader/template.go

  e.realizeBPFState() ->
  -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
  -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
  -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

  Uses epInfoCache

  --> Not vulnerable

* pkg/envoy/server.go

  e.updateNetworkPolicy() -> UpdateNetworkPolicy()

  The endpoint is locked. Must use a non-locking variation.

  --> Not vulnerable

* pkg/hubble/parser/threefour/parser.go

  Decode() -> resolveEndpoint()

  --> Vulnerable

Fixes: #11932

Signed-off-by: Thomas Graf <thomas@cilium.io>
@tgraf tgraf closed this as completed in 10f4e2c Jun 8, 2020
joestringer pushed a commit that referenced this issue Jun 8, 2020
[ upstream commit 10f4e2c ]

[ Backporter's notes: Minor conflicts scattered across five files. ]

Calls to GetIdentity() have been assuming both that the endpoint is
locked or not locked.

* daemon/cmd/fqdn.go / notifyOnDNSMsg():

  LookupEndpointIDByIP(). No locking.

  --> Vulnerable

* pkg/datapath/linux/config/config.go / writeStaticData()

  e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

  The endpoint is locked. Not using epCacheInfo. Must use a non-locking
  variation or a deadlock may occur.

  --> Not vulnerable

* pkg/datapath/loader/template.go

  e.realizeBPFState() ->
  -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
  -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
  -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

  Uses epInfoCache

  --> Not vulnerable

* pkg/envoy/server.go

  e.updateNetworkPolicy() -> UpdateNetworkPolicy()

  The endpoint is locked. Must use a non-locking variation.

  --> Not vulnerable

* pkg/hubble/parser/threefour/parser.go

  Decode() -> resolveEndpoint()

  --> Vulnerable

Fixes: #11932

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Joe Stringer <joe@cilium.io>
aanm pushed a commit that referenced this issue Jun 9, 2020
[ upstream commit 10f4e2c ]

Calls to GetIdentity() have been assuming both that the endpoint is
locked or not locked.

* daemon/cmd/fqdn.go / notifyOnDNSMsg():

  LookupEndpointIDByIP(). No locking.

  --> Vulnerable

* pkg/datapath/linux/config/config.go / writeStaticData()

  e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

  The endpoint is locked. Not using epCacheInfo. Must use a non-locking
  variation or a deadlock may occur.

  --> Not vulnerable

* pkg/datapath/loader/template.go

  e.realizeBPFState() ->
  -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
  -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
  -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

  Uses epInfoCache

  --> Not vulnerable

* pkg/envoy/server.go

  e.updateNetworkPolicy() -> UpdateNetworkPolicy()

  The endpoint is locked. Must use a non-locking variation.

  --> Not vulnerable

* pkg/hubble/parser/threefour/parser.go

  Decode() -> resolveEndpoint()

  --> Vulnerable

Fixes: #11932

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: André Martins <andre@cilium.io>
aanm pushed a commit that referenced this issue Jun 10, 2020
[ upstream commit 10f4e2c ]

Calls to GetIdentity() have been assuming both that the endpoint is
locked or not locked.

* daemon/cmd/fqdn.go / notifyOnDNSMsg():

  LookupEndpointIDByIP(). No locking.

  --> Vulnerable

* pkg/datapath/linux/config/config.go / writeStaticData()

  e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

  The endpoint is locked. Not using epCacheInfo. Must use a non-locking
  variation or a deadlock may occur.

  --> Not vulnerable

* pkg/datapath/loader/template.go

  e.realizeBPFState() ->
  -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
  -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
  -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

  Uses epInfoCache

  --> Not vulnerable

* pkg/envoy/server.go

  e.updateNetworkPolicy() -> UpdateNetworkPolicy()

  The endpoint is locked. Must use a non-locking variation.

  --> Not vulnerable

* pkg/hubble/parser/threefour/parser.go

  Decode() -> resolveEndpoint()

  --> Vulnerable

Fixes: #11932

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: André Martins <andre@cilium.io>
errordeveloper pushed a commit that referenced this issue Jun 10, 2020
[ upstream commit 10f4e2c ]

[ Backporter's notes: Minor conflicts scattered across five files. ]

Calls to GetIdentity() have been assuming both that the endpoint is
locked or not locked.

* daemon/cmd/fqdn.go / notifyOnDNSMsg():

  LookupEndpointIDByIP(). No locking.

  --> Vulnerable

* pkg/datapath/linux/config/config.go / writeStaticData()

  e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

  The endpoint is locked. Not using epCacheInfo. Must use a non-locking
  variation or a deadlock may occur.

  --> Not vulnerable

* pkg/datapath/loader/template.go

  e.realizeBPFState() ->
  -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
  -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
  -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

  Uses epInfoCache

  --> Not vulnerable

* pkg/envoy/server.go

  e.updateNetworkPolicy() -> UpdateNetworkPolicy()

  The endpoint is locked. Must use a non-locking variation.

  --> Not vulnerable

* pkg/hubble/parser/threefour/parser.go

  Decode() -> resolveEndpoint()

  --> Vulnerable

Fixes: #11932

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Joe Stringer <joe@cilium.io>
joestringer pushed a commit that referenced this issue Jun 12, 2020
[ upstream commit 10f4e2c ]

[ Backporter's notes: Several minor conflicts, simple resolution.
                      One extra previously-unnecessary function call
		      change in pkg/proxy/epinfo.go. ]

Calls to GetIdentity() have been assuming both that the endpoint is
locked or not locked.

* daemon/cmd/fqdn.go / notifyOnDNSMsg():

  LookupEndpointIDByIP(). No locking.

  --> Vulnerable

* pkg/datapath/linux/config/config.go / writeStaticData()

  e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

  The endpoint is locked. Not using epCacheInfo. Must use a non-locking
  variation or a deadlock may occur.

  --> Not vulnerable

* pkg/datapath/loader/template.go

  e.realizeBPFState() ->
  -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
  -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
  -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

  Uses epInfoCache

  --> Not vulnerable

* pkg/envoy/server.go

  e.updateNetworkPolicy() -> UpdateNetworkPolicy()

  The endpoint is locked. Must use a non-locking variation.

  --> Not vulnerable

* pkg/hubble/parser/threefour/parser.go

  Decode() -> resolveEndpoint()

  --> Vulnerable

Fixes: #11932

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Joe Stringer <joe@cilium.io>
joestringer pushed a commit that referenced this issue Jun 12, 2020
[ upstream commit 10f4e2c ]

[ Backporter's notes: Several minor conflicts, simple resolution.
                      One extra previously-unnecessary function call
		      change in pkg/proxy/epinfo.go. ]

Calls to GetIdentity() have been assuming both that the endpoint is
locked or not locked.

* daemon/cmd/fqdn.go / notifyOnDNSMsg():

  LookupEndpointIDByIP(). No locking.

  --> Vulnerable

* pkg/datapath/linux/config/config.go / writeStaticData()

  e.owner.Datapath().WriteEndpointConfig -> WriteEndpointConfig() -> writeStaticData()

  The endpoint is locked. Not using epCacheInfo. Must use a non-locking
  variation or a deadlock may occur.

  --> Not vulnerable

* pkg/datapath/loader/template.go

  e.realizeBPFState() ->
  -> CompileOrLoad -> ELFSubstitutions() -> elfVariableSubstitutions()
  -> CompileAndLoad() -> compileAndLoad() -> realizeBPFState() -> ReloadDatapath() ->
  -> ReloadDatapath() -> reloadHostDatapath() -> patchHostNetdevDatapath() -> ELFSubstitutions() -> elfVariableSubstitutions()

  Uses epInfoCache

  --> Not vulnerable

* pkg/envoy/server.go

  e.updateNetworkPolicy() -> UpdateNetworkPolicy()

  The endpoint is locked. Must use a non-locking variation.

  --> Not vulnerable

* pkg/hubble/parser/threefour/parser.go

  Decode() -> resolveEndpoint()

  --> Vulnerable

Fixes: #11932

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Joe Stringer <joe@cilium.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is a bug in the Cilium logic.
Projects
None yet
Development

No branches or pull requests

3 participants