-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8343020: (fs) Add support for SecureDirectoryStream on macOS #21696
Conversation
OpenJDK will not produce SecureDirectoryStreams on MacOS. Support for SecureDirectoryStream on UNIX-like OSes is predicated on the `SUPPORTS_OPENAT` flag in UnixNativeDispatcher. That flag in turn is set when the runtime environment supports `openat`, `fstatat`, `unlinkat`, `renameat`, `futimesat`, and `fdopendir`. This fails on MacOS because `futimesat` does not exist on that platform, apparently having been a proposed-but-not-accepted part of POSIX some time ago. While there is an indirect replacement that is supported on MacOS - `utimensat` - this is not actually needed, because the unique functionality provided by `futimesat` (that is, performing the action of `futimes` relative to an open directory file descriptor) is not utilized, since the only place this function is used passes `NULL` as the relative filename argument. Replacing this with simply calling `futimes` instead allows `SecureDirectoryStream` to function on MacOS.
👋 Welcome back dmlloyd! A progress list of the required criteria for merging this PR into |
@dmlloyd This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 32 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@bplb, @AlanBateman) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
There is no |
I'm seeing a build failure on macosx-x64 on both my own machine and in the CI:
The platforms |
DirectoryStream/SecureDS.java is the test for this API. Right now it only runs on Linux (it used to run on Solaris too). If support is extended to macOS then we'll need to change this test to use |
Can you see if -Xlog:init=debug to see if it reveals anything? I have a vague memory of issues futimes not being supported on some versions of macOS or Linux and we had to use futimesat instead. Switching to futimes means testing on a wide range of OS releases to make sure that aren't any issues. |
I was able to duplicate this, it does break the macosx-x64 build, I think it means tracking down which macOS versions have futimes. |
OK I'll see if I can figure out how to do this.
Luckily I still have a x64 mac so I can test this locally too. I think I can also try and see if |
The debug output is not revealing much (the boot module finder just returns Another logical discrepancy is that |
There's an unexpected plot twist. It turns out there's some kind of off-by-one problem when reading the directory when SDS is active. So the exceptions being thrown are like:
AFAICT this is coming out of |
After a lot of
I'm getting close! UPDATE: I've isolated the problem to not using UPDATE to the UPDATE: I've been stuck on what turns out to be a known problem with xcode 16: https://bugs.openjdk.org/browse/JDK-8340341 - hopefully I've got that solved now and we'll see what fix options we have for the actual problem. |
I found that after posting my question. |
OK the new version doesn't use |
I think the existing test will work still, because I don't see anything that restricts the OS, and the |
Never mind, I see: it will pass if everything is working, but it will also pass on macos if it's not working. So, I'll go ahead and make that change. |
I think you will need to add the issue ID to the |
… logic
The build now succeeds and the test passes on macOS-x64. Testing of other platforms is in progress. |
Build and test succeeded on |
/reviewers 2 reviewer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Please do not integrate until @AlanBateman has also approved, thanks.
Looking at related bug history, https://bugs.openjdk.org/browse/JDK-8214078 was considered a Bug not an Enhancement. What is the distinction? Is it due to being supported on other architectures on the same OS versus being unsupported by OS? Another question I had was: does this being an Enhancement affect backportability? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks okay.
It changes the Linux port from using futimesat to futimes. This should be okay as futimes has been available for a long time.
Change the macOS to not use dlsym is okay too, it had to use dlsym in the original port.
The update to the test looks okay.
SecureDirectoryStream is optional and this JBS issue is add support on macOS. So I think Enhancement is the right issue type. I don't think we can classify as a bug, it's just that this feature couldn't be implemented on macOS when the original port was done in 7u4. I'm not involved in update releases. |
/integrate |
/sponsor |
Going to push as commit 9f6d5b4.
Your commit was automatically rebased without conflicts. |
OpenJDK will not produce SecureDirectoryStreams on MacOS. Support for SecureDirectoryStream on UNIX-like OSes is predicated on the
SUPPORTS_OPENAT
flag in UnixNativeDispatcher. That flag in turn is set when the runtime environment supportsopenat
,fstatat
,unlinkat
,renameat
,futimesat
, andfdopendir
.This fails on MacOS because
futimesat
does not exist on that platform, apparently having been a proposed-but-not-accepted part of POSIX some time ago. While there is an indirect replacement that is supported on MacOS -utimensat
- this is not actually needed, because the unique functionality provided byfutimesat
(that is, performing the action offutimes
relative to an open directory file descriptor) is not utilized, since the only place this function is used passesNULL
as the relative filename argument.Replacing this with simply calling
futimes
instead allowsSecureDirectoryStream
to function on MacOS.Additionally, we must ensure that
openat
,fstatat
, andfdopendir
are properly detected on MacOS x64, because there are 32- and 64-bit variations on that platform which misbehave subtly when done improperly.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21696/head:pull/21696
$ git checkout pull/21696
Update a local copy of the PR:
$ git checkout pull/21696
$ git pull https://git.openjdk.org/jdk.git pull/21696/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21696
View PR using the GUI difftool:
$ git pr show -t 21696
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21696.diff
Webrev
Link to Webrev Comment