From fc9506866d98dcc745025551673e9c4c525e086b Mon Sep 17 00:00:00 2001 From: Dawn Minion Date: Tue, 3 Oct 2023 15:01:37 -0700 Subject: [PATCH] Clone OriginInfo in Path Clone OriginInfo assigned to Path objects is a pointer to the originating peer's info, which is populated by the FSM goroutine handling the peer's connection. This value is typically protected by the FSM lock, but in the event a path watch is running, it gets converted to a protobuf object in toPathAPI in a separate goroutine. This method reads from this same structure without any data synchronisation, leading to a data race. To ensure this cannot happen, this commit adds a line to clone the field before it is passed to the event watcher, ensuring the data race cannot occur. --- internal/pkg/table/path.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/pkg/table/path.go b/internal/pkg/table/path.go index 06da04dca..5cff1c4d9 100644 --- a/internal/pkg/table/path.go +++ b/internal/pkg/table/path.go @@ -328,11 +328,14 @@ func (path *Path) IsIBGP() bool { // create new PathAttributes func (path *Path) Clone(isWithdraw bool) *Path { + newOriginInfo := *path.info + return &Path{ parent: path, IsWithdraw: isWithdraw, IsNexthopInvalid: path.IsNexthopInvalid, attrsHash: path.attrsHash, + info: &newOriginInfo, } }