-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8345286: Remove use of SecurityManager API from misc areas #22478
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
Conversation
|
👋 Welcome back jpai! A progress list of the required criteria for merging this PR into |
|
@jaikiran 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 47 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. ➡️ To integrate this PR with the above commit message to the |
|
@jaikiran The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
|
Hello Severin @jerboaa, given your work in the cgroups area of the JDK, could you help review the updates in this PR for those classes? |
Webrevs
|
AlanBateman
left a comment
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.
Good cleanup, a few small nits spotted along the way.
| import java.security.AllPermission; | ||
| import java.security.CodeSource; | ||
| import java.security.PermissionCollection; | ||
| import java.security.PrivilegedExceptionAction; |
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'm half tempted to suggest leaving MethodUtil out of this change. There is further work required here and leaving the SM usage is a reminder of that.
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.
Understood. I've now updated this PR to revert back the changes in this file.
| } | ||
| catch (IOException e) { | ||
| try (BufferedReader bufferedReader = | ||
| Files.newBufferedReader(Paths.get(controller.path(), param))) { |
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.
The formatting has got messed up here. If you create Path path = Path.of(controller.path(), param) then the try line would fit on one line and would fix the formatting issue. Maybe some future cleanup will replace this with Files.lines as this just needs to return the first line.
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.
Fixed. I moved the Path.of() outside of the try-with-resources and the line length is now more reasonable.
| if (controller == null) return defaultRetval; | ||
|
|
||
| try (Stream<String> lines = CgroupUtil.readFilePrivileged(Paths.get(controller.path(), param))) { | ||
| try (Stream<String> lines = Files.lines(Paths.get(controller.path(), param))) { |
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.
Using Path.of might be clearer here.
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.
What Alan said.
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.
Done, here and one other place in this file.
| // construct PerfInstrumentation object | ||
| @SuppressWarnings("removal") | ||
| Perf perf = AccessController.doPrivileged(new Perf.GetPerfAction()); | ||
| Perf perf = Perf.getPerf(); |
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.
An extra space crept in that at some point
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.
Thanks for spotting that, I hadn't noticed it.
jerboaa
left a comment
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've reviewed only the cgroups parts.
| return CgroupUtil.readFilePrivileged(Paths.get(unified.path(), "io.stat")) | ||
| .map(mapFunc) | ||
| .collect(Collectors.summingLong(e -> e)); | ||
| try (Stream<String> lines = Files.lines(Paths.get(unified.path(), "io.stat"))) { |
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.
| try (Stream<String> lines = Files.lines(Paths.get(unified.path(), "io.stat"))) { | |
| try (Stream<String> lines = Files.lines(Paths.of(unified.path(), "io.stat"))) { |
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.
Done.
| try (BufferedReader bufferedReader = | ||
| Files.newBufferedReader(Paths.get(controller.path(), param))) { | ||
| String line = bufferedReader.readLine(); | ||
| return line; | ||
| } catch (IOException e) { |
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 we can do this refactoring now:
| try (BufferedReader bufferedReader = | |
| Files.newBufferedReader(Paths.get(controller.path(), param))) { | |
| String line = bufferedReader.readLine(); | |
| return line; | |
| } catch (IOException e) { | |
| try (Stream<String> lines = | |
| Files.lines(Paths.of(controller.path(), param))) { | |
| Optional<String> firstLine = lines.findFirst(); | |
| return firstLine.orElse(null); | |
| } catch (IOException e) { |
| if (controller == null) return defaultRetval; | ||
|
|
||
| try (Stream<String> lines = CgroupUtil.readFilePrivileged(Paths.get(controller.path(), param))) { | ||
| try (Stream<String> lines = Files.lines(Paths.get(controller.path(), param))) { |
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.
What Alan said.
src/java.base/linux/classes/jdk/internal/platform/cgroupv2/CgroupV2Subsystem.java
Outdated
Show resolved
Hide resolved
src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemController.java
Outdated
Show resolved
Hide resolved
…oupV2Subsystem.java Co-authored-by: Severin Gehwolf <jerboaa@gmail.com>
…temController.java Co-authored-by: Severin Gehwolf <jerboaa@gmail.com>
jerboaa
left a comment
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.
cgroups changes look good. Haven't looked at the other bits.
|
|
||
| package jdk.internal.platform; | ||
|
|
||
| import java.io.BufferedReader; |
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.
Unused now?
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.
Yes, it's now unused. I've removed it in the latest update to the PR and also replaced a few more Paths.get() with Path.of() in the current set of files that have been updated in this PR.
Thank you Severin. |
| @@ -1,5 +1,6 @@ | |||
| /* | |||
| * Copyright (c) 2020, 2022, Red Hat Inc. | |||
| * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. | |||
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.
Not sure about this as it's not a significant change to the file.
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.
Do you mean for just this file or the rest of the files in this PR as well? I am open to removing the copyright additions.
| /** | ||
| * Create a RandomIO object for all I/O of this Variant type. | ||
| */ | ||
| @SuppressWarnings("removal") |
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.
Sean has included in this one in the changes for sun.security (pull/22418) so I think you can drop it from this PR.
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.
Done. Removed it from this PR.
|
@jaikiran this pull request can not be integrated into git checkout 8345286
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
jerboaa
left a comment
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.
cgroup changes still look good.
dfuch
left a comment
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.
Good cleanup! Changes to logger + net look fine.
| Optional<String> firstLine = lines.findFirst(); | ||
| return firstLine.orElse(null); |
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.
you could probably just:
return lines.findFirst().orElse(null);
unless the local variable is needed or type inference?
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.
Hello Daniel, no syntactical reason behind this. Severin proposed this style in his review and I noticed that this area of the code has been using this style of local variable assigment and immediate return in one or two other places, so I decided to stick with it. I don't have a strong preference but am willing to update it if you or others think we should.
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.
In that case you may leave it as is - it's fine with me.
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| /** | ||
| * A thread that has no permissions, is not a member of any user-defined |
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 you can also remove the words "has no permissions" as it no longer applies. @AlanBateman ?
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.
Yes, that can be removed.
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.
Done.
|
Although trivial, there are some changes to files from the serviceability area. So it would be good if someone from that area could review this too. |
Yes, looks good. I will update #22478 to avoid the clash! |
|
Thank you everyone for the help in reviewing this. |
|
/integrate |
|
Going to push as commit 3d49665.
Your commit was automatically rebased without conflicts. |
Can I please get a review of this change which removes usages of SecurityManager related APIs and some leftover related to SecurityManager changes?
This addresses https://bugs.openjdk.org/browse/JDK-8345286. Most of these changes are trivial. The
src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.javaused to expose utility methods for dealing with SecurityManager permissions and it was called from a few places. That class is no longer needed with the clean up done in this PR.No new tests have been introduced and tier testing is currently in progress.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22478/head:pull/22478$ git checkout pull/22478Update a local copy of the PR:
$ git checkout pull/22478$ git pull https://git.openjdk.org/jdk.git pull/22478/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22478View PR using the GUI difftool:
$ git pr show -t 22478Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22478.diff
Using Webrev
Link to Webrev Comment