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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible fd leak and closing of dirs in doSafeMakeDir #79534

Merged
merged 1 commit into from Jul 1, 2019

Conversation

@odinuge
Copy link
Member

commented Jun 28, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug

/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
This fixes the issue where "childFD" from syscall.Openat is assigned to
a local variable inside the for loop, instead of the correct one in the
function scope. This results in that when trying to close the "childFD"
in the function scope, it will be equal to "-1", instead of the correct
value.

No huge chance of an fd leak, but better safe than sorry 馃し鈥嶁檪

doSafeOpen is very similar, but has correct handling of this.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fix possible fd leak and closing of dirs in doSafeMakeDir 
This fixes the issue where "childFD" from syscall.Openat is assigned to
a local variable inside the for loop, instead of the correct one in the
function scope. This results in that when trying to close the "childFD"
in the function scope, it will be equal to "-1", instead of the correct
value.
@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

Hi @odinuge. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

/sig storage

/cc @BenTheElder

@k8s-ci-robot k8s-ci-robot requested a review from BenTheElder Jun 28, 2019
@k8s-ci-robot k8s-ci-robot added sig/storage and removed needs-sig labels Jun 28, 2019
@k8s-ci-robot k8s-ci-robot requested review from jsafrane and msau42 Jun 28, 2019
@msau42

This comment has been minimized.

Copy link
Member

commented Jun 28, 2019

/assign

@BenTheElder

This comment has been minimized.

Copy link
Member

commented Jun 28, 2019

Nice catch!
/ok-to-test

@BenTheElder

This comment has been minimized.

Copy link
Member

commented Jul 1, 2019

/priority important-longterm

@odinuge odinuge referenced this pull request Jul 1, 2019
6 of 6 tasks complete
@msau42

This comment has been minimized.

Copy link
Member

commented Jul 1, 2019

/lgtm

Thanks for finding and fixing this!

@k8s-ci-robot k8s-ci-robot added the lgtm label Jul 1, 2019
@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jul 1, 2019

/assign @saad-ali

@msau42

This comment has been minimized.

Copy link
Member

commented Jul 1, 2019

/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: msau42, odinuge

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@odinuge

This comment has been minimized.

Copy link
Member Author

commented Jul 1, 2019

Looks like this was introduced here @msau42: #61044 (and then moved to another file).

Is this so important that you think we should back port it, or is it ok to just get it into master?

@msau42

This comment has been minimized.

Copy link
Member

commented Jul 1, 2019

I think it would be good to backport it

@k8s-ci-robot k8s-ci-robot merged commit a5e3d74 into kubernetes:master Jul 1, 2019
23 checks passed
23 checks passed
cla/linuxfoundation odinuge authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-cross Skipped.
pull-kubernetes-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-iscsi Skipped.
pull-kubernetes-e2e-gce-iscsi-serial Skipped.
pull-kubernetes-e2e-gce-storage-slow Job succeeded.
Details
pull-kubernetes-godeps Skipped.
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped.
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-node-e2e-containerd Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.
tide In merge pool.
Details
k8s-ci-robot added a commit that referenced this pull request Jul 3, 2019
鈥4-upstream-release-1.14

Automated cherry pick of #79534: Fix closing of dirs in doSafeMakeDir
k8s-ci-robot added a commit that referenced this pull request Jul 3, 2019
鈥4-upstream-release-1.13

Automated cherry pick of #79534: Fix closing of dirs in doSafeMakeDir
k8s-ci-robot added a commit that referenced this pull request Jul 4, 2019
鈥4-upstream-release-1.15

Automated cherry pick of #79534: Fix closing of dirs in doSafeMakeDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.