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

Don't re-initialize package level var native to fix data race #637

Merged
merged 1 commit into from
May 10, 2021

Conversation

tklauser
Copy link
Contributor

@tklauser tklauser commented Apr 12, 2021

The package level var native (holding the native endianness) is
initialized at package load time. Thus there is no need to re-initalize
it in (*Handle).filterModify, parseU32Data, parseFwData, parseBpfData
and parseMatchAllData. This fixes a data race between these functions
and any read access of var native, e.g. in LinkDeserialize as reported
in issue #633.

The second commit, while not directly related to the data race drops local re-declarations of var native using native := NativeEndian(). Instead the package-level global var can be used

Fixes #633

@tklauser
Copy link
Contributor Author

@aboch PTAL

@aboch
Copy link
Collaborator

aboch commented May 8, 2021

image

👍

@aboch
Copy link
Collaborator

aboch commented May 8, 2021

pls push again so CI is triggered

@aboch
Copy link
Collaborator

aboch commented May 8, 2021

LGTM

@tklauser
Copy link
Contributor Author

tklauser commented May 8, 2021

pls push again so CI is triggered

done, rebased and pushed again

@aboch
Copy link
Collaborator

aboch commented May 9, 2021

please squash your two commits into one

@tklauser
Copy link
Contributor Author

please squash your two commits into one

done

The package level var native (holding the native endianness) is
initialized at package load time. Thus there is no need to re-initalize
it in functions using it, e.g. (*Handle).filterModify, parseU32Data,
parseFwData, parseBpfData and parseMatchAllData.

This fixes a data race between these functions and any read access of
var native, e.g. in LinkDeserialize as reported in issue vishvananda#633.

Also don't re-declare local variables shadowing the global package-level
var.

Fixes vishvananda#633

Signed-off-by: Tobias Klauser <tobias@cilium.io>
@aboch aboch merged commit 4ef7bcb into vishvananda:master May 10, 2021
@tklauser tklauser deleted the fix-data-race-native branch May 10, 2021 14:32
tklauser added a commit to tklauser/netlink that referenced this pull request May 10, 2021
…hOptions

This was missed in vishvananda#637 due to it being introduced by vishvananda#623, which was
merged just recently.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
aboch pushed a commit that referenced this pull request May 10, 2021
…hOptions

This was missed in #637 due to it being introduced by #623, which was
merged just recently.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
tklauser added a commit to cilium/cilium that referenced this pull request May 10, 2021
This pulls in vishvananda/netlink#637 and
vishvananda/netlink#648 with data race fixes.

Fixes #15438

Signed-off-by: Tobias Klauser <tobias@cilium.io>
jrajahalme pushed a commit to cilium/cilium that referenced this pull request May 11, 2021
This pulls in vishvananda/netlink#637 and
vishvananda/netlink#648 with data race fixes.

Fixes #15438

Signed-off-by: Tobias Klauser <tobias@cilium.io>
glibsm pushed a commit to glibsm/cilium that referenced this pull request May 12, 2021
[ upstream commit f7bd191 ]

This pulls in vishvananda/netlink#637 and
vishvananda/netlink#648 with data race fixes.

Fixes cilium#15438

Signed-off-by: Tobias Klauser <tobias@cilium.io>
Signed-off-by: Glib Smaga <code@gsmaga.com>
aanm pushed a commit to cilium/cilium that referenced this pull request May 13, 2021
[ upstream commit f7bd191 ]

This pulls in vishvananda/netlink#637 and
vishvananda/netlink#648 with data race fixes.

Fixes #15438

Signed-off-by: Tobias Klauser <tobias@cilium.io>
Signed-off-by: Glib Smaga <code@gsmaga.com>
gkodali-zededa pushed a commit to gkodali-zededa/netlink that referenced this pull request May 21, 2021
…hOptions

This was missed in vishvananda#637 due to it being introduced by vishvananda#623, which was
merged just recently.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
cyberys pushed a commit to cyberys/netlink that referenced this pull request Apr 5, 2022
…hOptions

This was missed in vishvananda#637 due to it being introduced by vishvananda#623, which was
merged just recently.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
cjmakes pushed a commit to cjmakes/netlink that referenced this pull request Jun 29, 2022
…hOptions

This was missed in vishvananda#637 due to it being introduced by vishvananda#623, which was
merged just recently.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data race between parseBpfData() and LinkDeserialize()
2 participants