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

os: add support for long path names on unix RemoveAll #27871

Closed

Conversation

ostenbom
Copy link
Contributor

@ostenbom ostenbom commented Sep 26, 2018

On unix systems, long enough path names will fail when performing syscalls
like Lstat. The current RemoveAll uses several of these syscalls, and so
will fail for long paths. This can be risky, as it can let users "hide"
files from the system or otherwise make long enough paths for programs
to fail. By using Unlinkat and Openat syscalls instead, RemoveAll is
safer on unix systems. Initially implemented for linux, darwin, and several bsds.

Fixes #27029

Co-authored-by: Giuseppe Capizzi gcapizzi@pivotal.io
Co-authored-by: Julia Nedialkova yulia.nedyalkova@sap.com

@googlebot googlebot added the cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change. label Sep 26, 2018
@gopherbot
Copy link
Contributor

This PR (HEAD: 3043fe3) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/137442 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
Within the next week or so, a maintainer will review your change and provide
feedback. See https://golang.org/doc/contribute.html#review for more info and
tips to get your patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11, it means that this CL will be reviewed as part of the next development
cycle. See https://golang.org/s/release for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 12446:

Uploaded patch set 2: Commit message was updated.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 24096:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: e12cec7) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/137442 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gerrit User 19560:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 28776:

Patch Set 3:

(2 comments)

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: df255c8) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/137442 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gerrit User 28776:

Patch Set 4:

(1 comment)

Fixed to use existing syscall package constants. AT_REMOVEDIR was actually _AT_REMOVEDIR, so had to keep the 0x200 constant.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 19560:

Patch Set 4: Run-TryBot+1

Patch Set 4:

(1 comment)

Fixed to use existing syscall package constants. AT_REMOVEDIR was actually _AT_REMOVEDIR, so had to keep the 0x200 constant.

Thanks


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 4:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=d0a82701


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 4:

Build is still in progress...
This change failed on freebsd-amd64-11_1:
See https://storage.googleapis.com/go-build-log/d0a82701/freebsd-amd64-11_1_6e850e38.log

Consult https://build.golang.org/ to see whether it's a new failure. Other builds still in progress; subsequent failure notices suppressed until final report.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 4: TryBot-Result-1

2 of 19 TryBots failed:
Failed on freebsd-amd64-11_1: https://storage.googleapis.com/go-build-log/d0a82701/freebsd-amd64-11_1_6e850e38.log
Failed on openbsd-amd64-62: https://storage.googleapis.com/go-build-log/d0a82701/openbsd-amd64-62_8ae02b2c.log

Consult https://build.golang.org/ to see whether they are new failures.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 28776:

Patch Set 4:

Need some advice on removing "." and "..".

The reason for the freebsd/openbsd failures is because we added a TestRemoveAllDot test, testing for the removal of "." and ".." (usually not allowed on unix), which expects an error.

Do you agree with this reasoning? If so, we should just skip these tests on !linux,!darwin until it's ported.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: f616868) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/137442 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gerrit User 28776:

Patch Set 5:

Fixed by implementing for freebsd & openbsd


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5889:

Patch Set 5:

Patch Set 5:

Fixed by implementing for freebsd & openbsd

Were you going to enable it for them?


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 3cafab3) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/137442 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gerrit User 12446:

Uploaded patch set 7: Commit message was updated.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 28776:

Patch Set 6:

Patch Set 5:

Patch Set 5:

Fixed by implementing for freebsd & openbsd

Were you going to enable it for them?

Yep, always forgetting build flags. Have enabled for them now.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 19560:

Patch Set 7:

Patch Set 5:

Fixed by implementing for freebsd & openbsd

I think you can also cover netbsd and dragonfly in the same way. We don't have TryBots for these but I guess TestRemoveAllDot would still fail later on the builders.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 9ab706c) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/137442 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gerrit User 12446:

Uploaded patch set 9: Commit message was updated.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 28776:

Patch Set 8:

Patch Set 7:

Patch Set 5:

Fixed by implementing for freebsd & openbsd

I think you can also cover netbsd and dragonfly in the same way. We don't have TryBots for these but I guess TestRemoveAllDot would still fail later on the builders.

Yes you're right. Should be done for most unix systems now - maybe time for another trybot?


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

On unix systems, long enough path names will fail when performing syscalls
like `Lstat`. The current RemoveAll uses several of these syscalls, and so
will fail for long paths. This can be risky, as it can let users "hide"
files from the system or otherwise make long enough paths for programs
to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is
safer on unix systems. Initially implemented for linux, darwin, freebsd
and openbsd.

Fixes golang#27029

Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com>
@ianlancetaylor ianlancetaylor added cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change. and removed cla: no Used by googlebot to label PRs as having an invalid CLA. The text of this label should not change. labels Oct 30, 2018
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

@gopherbot
Copy link
Contributor

Message from Gerrit User 29433:

Patch Set 19:

Patch Set 19:

(1 comment)

Cleaned up the uintptr consts and used syscall.SYS_FSTATAT(64) references on supported architectures.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 29433:

Patch Set 20:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 19560:

Patch Set 20:

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 29433:

Patch Set 20:

(1 comment)

Ah, now I see the (new)fstatat(64) overlap, thanks Tobias. I managed to reduce all of the sysnum_linux_* files down to 3 using the 3 different calls. Again should come through when a googler thumbs up on the github PR.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 19560:

Patch Set 20:

Patch Set 20:

(1 comment)

Ah, now I see the (new)fstatat(64) overlap, thanks Tobias. I managed to reduce all of the sysnum_linux_* files down to 3 using the 3 different calls. Again should come through when a googler thumbs up on the github PR.

Nice, thanks a lot for working on these issues.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: b30a621) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/137442 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gerrit User 19560:

Patch Set 21: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 21:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=907b827e


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 21:

Build is still in progress...
This change failed on windows-amd64-2016:
See https://storage.googleapis.com/go-build-log/907b827e/windows-amd64-2016_a63ee959.log

Consult https://build.golang.org/ to see whether it's a new failure. Other builds still in progress; subsequent failure notices suppressed until final report.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 21: TryBot-Result-1

1 of 19 TryBots failed:
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/907b827e/windows-amd64-2016_a63ee959.log

Consult https://build.golang.org/ to see whether they are new failures.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 19560:

Patch Set 21:

Patch Set 21: TryBot-Result-1

1 of 19 TryBots failed:
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/907b827e/windows-amd64-2016_a63ee959.log

Consult https://build.golang.org/ to see whether they are new failures.

TryBot failure looks unrelated:

--- FAIL: TestReadSubKeyNames (0.00s)
registry_test.go:39: Access is denied.
FAIL
FAIL internal/syscall/windows/registry 0.151s


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5206:

Patch Set 21: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5206:

Patch Set 21: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5206:

Patch Set 22: Patch Set 21 was rebased


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5206:

Patch Set 22: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 22:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=8853b41f


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 21: TryBot-Result+1

TryBots are happy.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 22:

Build is still in progress...
This change failed on freebsd-amd64-11_1:
See https://storage.googleapis.com/go-build-log/8853b41f/freebsd-amd64-11_1_4f1cf3bb.log

Consult https://build.golang.org/ to see whether it's a new failure. Other builds still in progress; subsequent failure notices suppressed until final report.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gerrit User 5976:

Patch Set 22: TryBot-Result-1

1 of 19 TryBots failed:
Failed on freebsd-amd64-11_1: https://storage.googleapis.com/go-build-log/8853b41f/freebsd-amd64-11_1_4f1cf3bb.log

Consult https://build.golang.org/ to see whether they are new failures.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Oct 30, 2018
On unix systems, long enough path names will fail when performing syscalls
like `Lstat`. The current RemoveAll uses several of these syscalls, and so
will fail for long paths. This can be risky, as it can let users "hide"
files from the system or otherwise make long enough paths for programs
to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is
safer on unix systems. Initially implemented for linux, darwin, and several bsds.

Fixes #27029

Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com>

Change-Id: Id9fcdf4775962b021b7ff438dc51ee6d16bb5f56
GitHub-Last-Rev: b30a621
GitHub-Pull-Request: #27871
Reviewed-on: https://go-review.googlesource.com/c/137442
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot
Copy link
Contributor

Message from Gerrit User 5206:

Patch Set 22: Code-Review+2

OK, looks good. Whew. Thanks for your patience on this.


Please don’t reply on this GitHub thread. Visit golang.org/cl/137442.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/137442 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants