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

8344034: Remove security manager dependency in Serialization #22041

Closed
Closed
Show file tree
Hide file tree
Changes from 230 commits
Commits
Show all changes
234 commits
Select commit Hold shift + click to select a range
ef70021
Initial load of JEP 486 implementation
AlanBateman Sep 30, 2024
591d3d6
ServerSocket bind/accept no longer throw SecurityException
AlanBateman Oct 1, 2024
781eecd
Merge
AlanBateman Oct 1, 2024
4035376
hack out Security Manager from LoaderHandler
stuart-marks Aug 24, 2024
6d2006d
Update spec for RMIClassLoader
stuart-marks Aug 30, 2024
6c325c2
Fix whitespace.
stuart-marks Sep 26, 2024
463d46b
Restore URL parsing to LoaderHandler::getClassLoader.
stuart-marks Oct 1, 2024
439ed26
Merge
AlanBateman Oct 2, 2024
53e06d0
Remove vmTestbase/nsk/jvmti/AttachOnDemand/attach004/TestDescription.…
AlanBateman Oct 2, 2024
9e1cec8
Remove leftover SecurityException text from RMIConnection.getObjectIn…
seanjmullan Oct 2, 2024
7cf5824
Remove leftover "@see java.lang.SecurityManager#checkSetFactory" from
seanjmullan Oct 2, 2024
77b58bf
Remove unnecessary comma.
seanjmullan Oct 2, 2024
b5f2ca3
Merge
AlanBateman Oct 3, 2024
938737a
Fix typo.
seanjmullan Oct 3, 2024
2612400
Remove text about granting permission and add api note indicating
seanjmullan Oct 3, 2024
4688f78
Remove text about implementers using Security Manager checks from class
seanjmullan Oct 3, 2024
34da8c7
Remove Security Manager text from EXIT_ON_CLOSE.
seanjmullan Oct 3, 2024
c62c4ad
Removed TestSecurityManagerChecks.java - this test was testing permis…
seanjmullan Oct 3, 2024
d8e15dd
Drop reference to permissions from Font.getFont
AlanBateman Oct 4, 2024
29c0bb2
Merge
AlanBateman Oct 4, 2024
23e0f09
Update record tests to not require SM
AlanBateman Oct 4, 2024
bd27286
Remove tests for repeating annotations with SM set, no SM case well t…
AlanBateman Oct 4, 2024
7f451ea
Change reflect/Nestmates/TestReflectionAPI to not test with a SM set
AlanBateman Oct 4, 2024
c9ab253
Remove test/langtools/tools/javac/api/ToolProvider/ToolProviderTest.j…
AlanBateman Oct 4, 2024
36522ed
Remove text about granting permissions to module from
seanjmullan Oct 4, 2024
c769f2d
Remove text about Proxy objects being granted AllPermission.
seanjmullan Oct 4, 2024
79b4b21
Remove text about needing ReflectPermission to access AccessibleObject.
seanjmullan Oct 4, 2024
e46d99c
JDK-8003881: Prevent lambda implementing inner classes from allowing …
igraves Oct 4, 2024
422c489
JDK-8007035: deprecate public void SecurityManager.checkMemberAccess(…
igraves Oct 4, 2024
1f4be6f
Update copyright header
AlanBateman Oct 5, 2024
87f5a53
Merge
AlanBateman Oct 5, 2024
edcafbb
Remove text about using group from SM if null from constructor.
seanjmullan Oct 5, 2024
dc6e158
Remove text from class description about common pools when SM is enab…
seanjmullan Oct 5, 2024
09f5ffd
Merge
AlanBateman Oct 5, 2024
97c28c4
Fix typo.
seanjmullan Oct 5, 2024
0fab6e0
Remove leftover checkListen text from @throws SecurityException in bi…
seanjmullan Oct 5, 2024
901decf
Some wording changes to deprecated text.
seanjmullan Oct 5, 2024
1702b47
Remove @see SM.checkConnect
AlanBateman Oct 7, 2024
a5629a2
Remove uses of "security check" from docs
AlanBateman Oct 7, 2024
cc4d56d
Remove left over refs to security checks
AlanBateman Oct 7, 2024
2b4a91d
Remove Security section from SL spec
AlanBateman Oct 7, 2024
cf4adb9
Tweak deprecated text.
seanjmullan Oct 7, 2024
1f3df69
More tweaks to deprecated text.
seanjmullan Oct 7, 2024
23bd997
Fix typo.
seanjmullan Oct 7, 2024
ca96a40
SecurityManager::getClassContext includes additional frame
AlanBateman Oct 7, 2024
425e72f
Remove SM dependency from tools/doclint/tool/RunTest.java. Change test
seanjmullan Oct 7, 2024
d43e0a9
Remove java/lang/constant/methodTypeDesc/ResolveConstantDesc.java, no…
AlanBateman Oct 7, 2024
281ceba
Tweak deprecation text.
seanjmullan Oct 7, 2024
9f17137
In defineClass, remove text about granted permissions to default domain.
seanjmullan Oct 7, 2024
a598567
Make specification more clear about default domain containing no perms.
seanjmullan Oct 7, 2024
25d8f26
Remove SM test case from tools/javac/launcher/SourceLauncherTest.java…
seanjmullan Oct 7, 2024
b4a05bb
Remove text about needing RuntimePermission "getClassLoader" from
seanjmullan Oct 7, 2024
453b6c1
Merge
AlanBateman Oct 8, 2024
4c668e7
Replace "granted" wording in getPermissions() with "returned". Remove
seanjmullan Oct 8, 2024
57788cf
Remove jdk/dynalink/UntrustedDynamicLinkerFactoryTest.java test as it is
seanjmullan Oct 8, 2024
c863402
Restore policy file accidentally deleted.
seanjmullan Oct 8, 2024
2f354c4
8229785: MethodType::fromMethodDescriptorString should require securi…
igraves Oct 8, 2024
1d0edb6
8013527: calling MethodHandles.lookup on itself leads to errors
igraves Oct 8, 2024
a398888
8008688: Make MethodHandleInfo public
igraves Oct 8, 2024
e585a5e
8008688: Make MethodHandleInfo public
igraves Oct 8, 2024
a2ef07a
Removing errant swp file and updating SM problem list
igraves Oct 9, 2024
3aa4935
8076596: BytecodeDescriptor.parseMethod doesn't work during bootstrap…
igraves Oct 9, 2024
d6233e8
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 9, 2024
f0a776f
Remove java/lang/reflect/sealed_classes/TestSecurityManagerChecks.jav…
seanjmullan Oct 9, 2024
8d72878
7196190: Improve method of handling MethodHandles
igraves Oct 9, 2024
c8e800a
Merge
AlanBateman Oct 11, 2024
ac815f1
Move SM problem tests from ProblemList-sm.txt to ProblemList.txt.
seanjmullan Oct 11, 2024
958bb50
Remove runtime/Nestmates/protectionDomain/TestDifferentProtectionDoma…
seanjmullan Oct 11, 2024
2843729
Remove text about executing in caller's AccessControlContext from
seanjmullan Oct 11, 2024
1d0f8dd
Remove text from class description about invoking CallbackHandler's h…
seanjmullan Oct 11, 2024
b370c9b
Remove text about executing in caller's AccessControlContext from
seanjmullan Oct 11, 2024
a1973fa
Drop text on enforcement of security policies
AlanBateman Oct 12, 2024
875c480
Update copyright headers
AlanBateman Oct 12, 2024
f14f7fc
Merge
AlanBateman Oct 12, 2024
d3a4d2d
clientlibs: Updated Problemlist JBS ID for javax/swing/JPopupMenu/669…
honkar-jdk Oct 13, 2024
5d45bb1
Remove windows-specific policy file as it is no longer needed.
seanjmullan Oct 14, 2024
bc9697c
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 14, 2024
13601a1
Merge
AlanBateman Oct 14, 2024
a655f48
Fix whitespace
AlanBateman Oct 14, 2024
fd5824e
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 14, 2024
413cb48
fix setOpenURIHandler docs
prrace Oct 14, 2024
f7d0331
Merge
AlanBateman Oct 15, 2024
d05122f
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 15, 2024
c80c01f
Remove text and links to fine grained permissions docs.
seanjmullan Oct 15, 2024
0115b0f
Merge
AlanBateman Oct 16, 2024
2da3699
Merge
AlanBateman Oct 16, 2024
23a43e0
Revert changes to JMXAuthenticator and JMXConnectorFactory as these m…
seanjmullan Oct 16, 2024
d034341
Merge
AlanBateman Oct 17, 2024
2a4663c
Merge
AlanBateman Oct 18, 2024
2ebb6de
Change checkAccess() methods to be no-ops, rather than throwing
seanjmullan Oct 17, 2024
7ea65a6
Add api note to getClassContext to use StackWalker instead and
seanjmullan Oct 17, 2024
adf5ed7
Restore text about needing permissions from the desktop environment i…
seanjmullan Oct 17, 2024
44432e5
Add text to class description of MBeanServer stating that implementat…
seanjmullan Oct 17, 2024
86ff714
Restored methods in RMIConnection to throw SecurityExceptions again but
seanjmullan Oct 17, 2024
9dd59a1
Sanitize the class descriptions of DelegationPermission and ServicePe…
seanjmullan Oct 17, 2024
16e17b8
Change apiNote to deprecated annotation on checkAccess methods. Chang…
seanjmullan Oct 18, 2024
f89d9d0
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 18, 2024
14475d1
clientlibs: java/awt/Robot/InfiniteLoopException.java problemlisted
honkar-jdk Oct 18, 2024
fc10303
Merge
AlanBateman Oct 19, 2024
4f14027
Remove left over references to SecurityManager in tests
AlanBateman Oct 19, 2024
2f8242b
WhiteBox.getWhiteBox cleanup
AlanBateman Oct 19, 2024
8e8d388
Update test summary for tests that no longer run with SM set
AlanBateman Oct 19, 2024
e66d14a
Remove left over policy files
AlanBateman Oct 19, 2024
46970f8
Remove left over policy files
AlanBateman Oct 20, 2024
365acc1
test/langtools/tools/doclint/tool/RunTest.java failing with JTREG_TES…
AlanBateman Oct 20, 2024
6e5891f
Merge
AlanBateman Oct 21, 2024
02b4bf1
remove references to sm in pkcs11 tests
wangweij Oct 21, 2024
b4f68e3
two useless policy files
wangweij Oct 21, 2024
807eb6e
cleanup TestEC.java
wangweij Oct 21, 2024
f88f5d6
Remove redundant @see StackWalker from getClassContext.
seanjmullan Oct 21, 2024
9e831e2
Revert last copyright date as there are now no changes to this file.
seanjmullan Oct 21, 2024
848ed63
update copyright year for the recently updated tests
wangweij Oct 21, 2024
84ad071
this special rule no long applies since we have no PolicyFile class now
wangweij Oct 21, 2024
efd1b0f
in Subject, current() is only mostly equivalent to the original getSu…
wangweij Oct 21, 2024
4603119
Remove/modify microbenchmark tests that set an SM.
seanjmullan Oct 21, 2024
be38c74
Drop sentence about trusted system code from Proxy spec
AlanBateman Oct 21, 2024
d384416
Modify tools/javac/processing/6348193/T6348193.java test to not test
seanjmullan Oct 21, 2024
e8656ac
Remove 3 test cases from jdk/dynalink/BeanLinkerTest.java that depend…
seanjmullan Oct 21, 2024
1bf77a3
imageio cache
prrace Oct 21, 2024
ebd8a9e
Merge branch 'jep486' of github.com:openjdk/jdk-sandbox into jep486
prrace Oct 21, 2024
313fb8b
TestClassPathPlugin.sh
prrace Oct 21, 2024
7e53cfc
createfont
prrace Oct 21, 2024
75ddc00
policy
prrace Oct 21, 2024
3e509d7
Policy no longer links to standard-names.html
wangweij Oct 21, 2024
352b51e
warningwindow
prrace Oct 21, 2024
db88b58
Merge branch 'jep486' of github.com:openjdk/jdk-sandbox into jep486
prrace Oct 21, 2024
2a5d99c
dump.policy
prrace Oct 21, 2024
7c0e8e4
securitydialog
prrace Oct 21, 2024
72a1651
policy
prrace Oct 21, 2024
8383d78
policy
prrace Oct 21, 2024
8c32dc3
clientlibs: deleted policy files
honkar-jdk Oct 21, 2024
7205009
Merge
AlanBateman Oct 22, 2024
fa7f48a
Fix @run tag with the correct test name
AlanBateman Oct 22, 2024
0a26398
Modified jdk/dynalink/TrustedDynamicLinkerFactoryTest.java to run w/o…
seanjmullan Oct 22, 2024
c9f4db1
reword Subject spec
wangweij Oct 22, 2024
3a5f1fc
Remove compiler/exceptions/ExceptionInInit.java test - exception is no
seanjmullan Oct 22, 2024
d9ee496
clientlibs swing test review changes
honkar-jdk Oct 22, 2024
2c9b11d
Merge
AlanBateman Oct 23, 2024
7fbe121
Restore test/langtools/ProblemList.txt as not changed
AlanBateman Oct 23, 2024
82bb0d8
java/net/httpclient/websocket/security/WSURLPermissionTest.java renam…
dfuch Oct 23, 2024
3443975
java/net/httpclient/websocket/security/WSURLPermissionTest.java: inte…
dfuch Oct 23, 2024
300d3f9
warning-string
prrace Oct 23, 2024
d32e384
clientlibs: import order
honkar-jdk Oct 23, 2024
5599346
Remove hasSM() method and code that calls it, and remove comment about
seanjmullan Oct 23, 2024
d991534
Remove static variable `DEFAULT_POLICY` and unused imports.
seanjmullan Oct 23, 2024
3dbf684
Remove unused static variable NEW_PROXY_IN_PKG.
seanjmullan Oct 23, 2024
0022764
Remove println about Security Manager.
seanjmullan Oct 23, 2024
d8564fa
Update @summary to replace "if the right permission is granted" can b…
seanjmullan Oct 23, 2024
29e7e87
Merge
AlanBateman Oct 24, 2024
cb50dfd
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 24, 2024
2bc142e
SM related cleanup of Runtime exec ExecCommand test.
RogerRiggs Oct 24, 2024
de0a0f6
clientlibs: Deleted awt/Focus/CloseDialogActivateOwnerTest.java
honkar-jdk Oct 24, 2024
b78a7b6
clientlibs: Javadoc updates to src/java.desktop/
honkar-jdk Oct 24, 2024
3aa0054
Merge branch 'master' into jep486
AlanBateman Oct 25, 2024
e50cf64
Remove enum from test as it is no longer needed.
seanjmullan Oct 25, 2024
44b552a
Remove unnecessary "anymore" word from @apiNote in Permission subclas…
seanjmullan Oct 25, 2024
0f448e5
Fix typo.
seanjmullan Oct 25, 2024
a7a4944
clientlibs: copyright year updates
honkar-jdk Oct 25, 2024
1a2e1a8
no more support for permissions in Proc.java
wangweij Oct 25, 2024
bc59b55
Merge
AlanBateman Oct 25, 2024
17b5cc7
Merge
AlanBateman Oct 26, 2024
ed0f5c0
Fix type in addProvider.
seanjmullan Oct 25, 2024
7f86027
Remove apiNote. SM changes in smartcardio APIs should be done via JSR…
seanjmullan Oct 26, 2024
b6fe405
Change checkPermission exception msg to "checking permissions is not …
seanjmullan Oct 26, 2024
09b6cd6
Add missing class description.
seanjmullan Oct 26, 2024
8b527c9
Add api note to class description that permission checking is not sup…
seanjmullan Oct 26, 2024
275dabd
Change "SecurityManager" to "Security Manager". Add some missing code…
seanjmullan Oct 26, 2024
6614517
Restore note for implementers in src/java.prefs/share/classes/java/ut…
AlanBateman Oct 27, 2024
cd794a1
clientlibs: GetSoundBankSecurityException.java renamed to EmptySoundB…
honkar-jdk Oct 28, 2024
934e1c2
clientlibs: GetSoundBankSecurityException.java renamed to EmptySoundB…
honkar-jdk Oct 28, 2024
aca9555
clientlibs: Deleted JPopupMenu tests
honkar-jdk Oct 28, 2024
80514d9
clientlibs: Updated Problemlist
honkar-jdk Oct 28, 2024
6064562
Change deprecated annotations to api notes on getPolicy and setPolicy.
seanjmullan Oct 28, 2024
4981da0
Specify that params passed to getPermissions and implies are ignored and
seanjmullan Oct 28, 2024
e490f69
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 28, 2024
047e144
No need to override methods for private static NO_PERMISSIONS_POLICY.
seanjmullan Oct 28, 2024
9eb275c
clientlibs: Updated javax/swing/UIDefaults/6622002/bug6622002.java
honkar-jdk Oct 28, 2024
2a9b98e
remove non enforced/redundant comment in TestLogConfigurationDeadLock…
justin-curtis-lu Oct 28, 2024
8054d10
delete PermissionTest.java as it simply constructs provider impls
justin-curtis-lu Oct 28, 2024
bc5b3d7
remove privileged calls in logging/File* tests
justin-curtis-lu Oct 28, 2024
cb5f6e4
ResourceBundle/modules/security/* no longer needed. TestPermission te…
justin-curtis-lu Oct 28, 2024
fe73fd0
Merge branch 'master' into jep486
AlanBateman Oct 29, 2024
0feceaa
Adjust Executors.privilegedThreadFactory to make clear that thread us…
AlanBateman Oct 29, 2024
b654355
Update copyright headers
AlanBateman Oct 29, 2024
548eb9e
Update copyrights. Remove @compile line form Marshal.java test.
seanjmullan Oct 29, 2024
2f90c83
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 29, 2024
61dd3ba
Update definition of networkaddress.cache.ttl security property.
seanjmullan Oct 29, 2024
ee570c4
Update copyrights.
seanjmullan Oct 29, 2024
b2d59a4
Remove test - only checked that doPrivileged calls were in place.
seanjmullan Oct 29, 2024
7e72d14
Renamed test as it is not about permission checking anymore but still…
seanjmullan Oct 29, 2024
90469c2
clientlibs: Javadoc cleanup
honkar-jdk Oct 29, 2024
444fabe
rename TestAppletLoggerContext.java as suggested in util test review
justin-curtis-lu Oct 29, 2024
06c4c3c
Improve description of Executors.privilegedThreadFactory
AlanBateman Oct 29, 2024
5577e48
JAXP tests: organize imports of a few tests
JoeWang-Java Oct 29, 2024
1dbfe91
Merge branch 'master' into jep486
AlanBateman Oct 30, 2024
376d1b5
Added API Notes to ProtectionDomain clarifying that the current polic…
seanjmullan Oct 30, 2024
8772ee2
In staticPermissionsOnly(), change "current policy binding" to "curre…
seanjmullan Oct 30, 2024
1670907
Remove two obsolete RMI tests:
stuart-marks Oct 30, 2024
3fe3f59
Modify three RMI tests to work without the security manager:
stuart-marks Oct 30, 2024
7958ee2
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Oct 30, 2024
11f374a
Merge branch 'master' into jep486
AlanBateman Oct 31, 2024
aabb648
Update copyright headers
AlanBateman Oct 31, 2024
6033f47
clientlibs: Problemlisted manual tests
honkar-jdk Oct 31, 2024
440c4a3
Merge branch 'master' into jep486
AlanBateman Nov 1, 2024
c69dc5e
Merge branch 'master' into jep486
AlanBateman Nov 2, 2024
ab586f6
Remove left-over paragraph about SM use from LoggerFinder
AlanBateman Nov 3, 2024
9aad719
remove LauncherErrors test from problemlisting
jaikiran Nov 3, 2024
a2e151c
remove MainClassCantBeLoadedTest from problemlisting
jaikiran Nov 3, 2024
74352c3
Merge branch 'master' into jep486
AlanBateman Nov 3, 2024
f6e4b82
Merge branch 'jep486' of https://github.com/openjdk/jdk-sandbox into …
AlanBateman Nov 4, 2024
002f3f6
Merge branch 'master' into jep486
AlanBateman Nov 4, 2024
5866fa4
Remove "access" and "policy" options from debug help.
seanjmullan Nov 4, 2024
789c615
Merge branch 'master' into jep486
AlanBateman Nov 5, 2024
51d2a2a
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Nov 5, 2024
10164a3
Merge branch 'master' into jep486
AlanBateman Nov 5, 2024
5d5528a
Merge branch 'master' into jep486
AlanBateman Nov 5, 2024
e9e7f0c
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Nov 5, 2024
f4518b2
Merge branch 'master' into jep486
AlanBateman Nov 6, 2024
fe4ff47
Merge branch 'master' into jep486
AlanBateman Nov 7, 2024
b668e0d
test/jdk/java/rmi/server/RMIClassLoader/spi/DefaultProperty.java failing
AlanBateman Nov 7, 2024
353cb94
Move JEP 486 failing tests into hotspot_runtime group.
seanjmullan Nov 7, 2024
dfd44d6
Move remaining JEP 486 failing tests into correct groups.
seanjmullan Nov 7, 2024
ca8a528
Merge branch 'master' into jep486
AlanBateman Nov 8, 2024
6ad9192
Merge remote-tracking branch 'jdk-sandbox/jep486' into JDK-8338411
seanjmullan Nov 8, 2024
b45a76b
JDK-8344034: Remove security manager dependency in Serialization
RogerRiggs Nov 8, 2024
1317f47
Merge branch 'master' into 8344034-sm-removal-serialization
RogerRiggs Nov 12, 2024
3f85083
Cleanup of suppress warnings and caller sensitive from review comments.
RogerRiggs Nov 12, 2024
3e56ef0
Remove overlooked SecurityManager use in ObjectInputFilter and Object…
RogerRiggs Nov 13, 2024
8c1fc41
Remove CallerSensitive and suppress warnings
RogerRiggs Nov 13, 2024
054b410
Remove unused imports
RogerRiggs Nov 13, 2024
6e40d2c
Merge branch 'master' into 8344034-sm-removal-serialization
RogerRiggs Nov 14, 2024
b8e8d42
Fix test to longer check for CallerSensistive on ObjectStreamField.ge…
RogerRiggs Nov 14, 2024
bd82304
Wrap long lines
RogerRiggs Nov 14, 2024
c67a212
Wrap more long lines
RogerRiggs Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/java.base/share/classes/java/io/ObjectInputFilter.java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all usages of SecurityManager be removed from this class?

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import jdk.internal.util.StaticProperty;

import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -630,17 +628,13 @@ final class Config {
configLog = System.getLogger("java.io.serialization");

// Get the values of the system properties, if they are defined
@SuppressWarnings("removal")
String factoryClassName = StaticProperty.jdkSerialFilterFactory() != null
? StaticProperty.jdkSerialFilterFactory()
: AccessController.doPrivileged((PrivilegedAction<String>) () ->
Security.getProperty(SERIAL_FILTER_FACTORY_PROPNAME));
: Security.getProperty(SERIAL_FILTER_FACTORY_PROPNAME);

@SuppressWarnings("removal")
String filterString = StaticProperty.jdkSerialFilter() != null
? StaticProperty.jdkSerialFilter()
: AccessController.doPrivileged((PrivilegedAction<String>) () ->
Security.getProperty(SERIAL_FILTER_PROPNAME));
: Security.getProperty(SERIAL_FILTER_PROPNAME);

// Initialize the static filter if the jdk.serialFilter is present
String filterMessage = null;
Expand Down Expand Up @@ -734,11 +728,6 @@ public static ObjectInputFilter getSerialFilter() {
*/
public static void setSerialFilter(ObjectInputFilter filter) {
Objects.requireNonNull(filter, "filter");
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
}
if (invalidFilterMessage != null) {
throw new IllegalStateException(invalidFilterMessage);
}
Expand Down Expand Up @@ -831,11 +820,6 @@ static BinaryOperator<ObjectInputFilter> getSerialFilterFactorySingleton() {
*/
public static void setSerialFilterFactory(BinaryOperator<ObjectInputFilter> filterFactory) {
Objects.requireNonNull(filterFactory, "filterFactory");
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
}
if (filterFactoryNoReplace.getAndSet(true)) {
final String msg = serialFilterFactory != null
? "Cannot replace filter factory: " + serialFilterFactory.getClass().getName()
Expand Down
124 changes: 26 additions & 98 deletions src/java.base/share/classes/java/io/ObjectInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.nio.charset.StandardCharsets;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;

import jdk.internal.access.JavaLangAccess;
Expand All @@ -49,8 +43,6 @@
import jdk.internal.misc.Unsafe;
import jdk.internal.util.ByteArray;
import sun.reflect.misc.ReflectUtil;
import sun.security.action.GetBooleanAction;
import sun.security.action.GetIntegerAction;

/**
* An ObjectInputStream deserializes primitive data and objects previously
Expand Down Expand Up @@ -278,26 +270,24 @@ protected Boolean computeValue(Class<?> type) {
* have been read.
* See {@link #setObjectInputFilter(ObjectInputFilter)}
*/
static final boolean SET_FILTER_AFTER_READ = GetBooleanAction
.privilegedGetProperty("jdk.serialSetFilterAfterRead");
static final boolean SET_FILTER_AFTER_READ = Boolean.getBoolean("jdk.serialSetFilterAfterRead");

/**
* Property to control {@link GetField#get(String, Object)} conversion of
* {@link ClassNotFoundException} to {@code null}. If set to {@code true}
* {@link GetField#get(String, Object)} returns null otherwise
* throwing {@link ClassNotFoundException}.
*/
private static final boolean GETFIELD_CNFE_RETURNS_NULL = GetBooleanAction
.privilegedGetProperty("jdk.serialGetFieldCnfeReturnsNull");
private static final boolean GETFIELD_CNFE_RETURNS_NULL = Boolean.getBoolean("jdk.serialGetFieldCnfeReturnsNull");
RogerRiggs marked this conversation as resolved.
Show resolved Hide resolved

/**
* Property to override the implementation limit on the number
* of interfaces allowed for Proxies. The property value is clamped to 0..65535.
* The maximum number of interfaces allowed for a proxy is limited to 65535 by
* {@link java.lang.reflect.Proxy#newProxyInstance(ClassLoader, Class[], InvocationHandler)}.
*/
static final int PROXY_INTERFACE_LIMIT = Math.clamp(GetIntegerAction
.privilegedGetProperty("jdk.serialProxyInterfaceLimit", 65535), 0, 65535);
static final int PROXY_INTERFACE_LIMIT =
Math.clamp(Integer.getInteger("jdk.serialProxyInterfaceLimit", 65535), 0, 65535);
}

/*
Expand Down Expand Up @@ -386,7 +376,6 @@ private static class Logging {
*/
@SuppressWarnings("this-escape")
public ObjectInputStream(InputStream in) throws IOException {
verifySubclass();
bin = new BlockDataInputStream(in);
handles = new HandleTable(10);
vlist = new ValidationList();
Expand Down Expand Up @@ -416,11 +405,6 @@ public ObjectInputStream(InputStream in) throws IOException {
* fails due to invalid serial filter or serial filter factory properties.
*/
protected ObjectInputStream() throws IOException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
}
bin = null;
handles = null;
vlist = null;
Expand Down Expand Up @@ -907,13 +891,6 @@ protected boolean enableResolveObject(boolean enable) {
if (enable == enableResolve) {
return enable;
}
if (enable) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SUBSTITUTION_PERMISSION);
}
}
enableResolve = enable;
return !enableResolve;
}
Expand Down Expand Up @@ -1309,11 +1286,6 @@ public final ObjectInputFilter getObjectInputFilter() {
* @since 9
*/
public final void setObjectInputFilter(ObjectInputFilter filter) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
}
if (totalObjectRefs > 0 && !Caches.SET_FILTER_AFTER_READ) {
throw new IllegalStateException(
"filter can not be set after an object has been read");
Expand Down Expand Up @@ -1571,58 +1543,29 @@ public abstract boolean get(String name, boolean val)
public abstract Object get(String name, Object val) throws IOException, ClassNotFoundException;
}

/**
* Verifies that this (possibly subclass) instance can be constructed
* without violating security constraints: the subclass must not override
* security-sensitive non-final methods, or else the
* "enableSubclassImplementation" SerializablePermission is checked.
*/
private void verifySubclass() {
Class<?> cl = getClass();
if (cl == ObjectInputStream.class) {
return;
}
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm == null) {
return;
}
boolean result = Caches.subclassAudits.get(cl);
if (!result) {
sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
}
}

/**
* Performs reflective checks on given subclass to verify that it doesn't
* override security-sensitive non-final methods. Returns TRUE if subclass
* is "safe", FALSE otherwise.
*/
@SuppressWarnings("removal")
private static Boolean auditSubclass(Class<?> subcl) {
return AccessController.doPrivileged(
new PrivilegedAction<Boolean>() {
public Boolean run() {
for (Class<?> cl = subcl;
cl != ObjectInputStream.class;
cl = cl.getSuperclass())
{
try {
cl.getDeclaredMethod(
"readUnshared", (Class[]) null);
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
try {
cl.getDeclaredMethod("readFields", (Class[]) null);
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
}
return Boolean.TRUE;
}
for (Class<?> cl = subcl;
cl != ObjectInputStream.class;
cl = cl.getSuperclass())
{
try {
cl.getDeclaredMethod(
"readUnshared", (Class[]) null);
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
);
try {
cl.getDeclaredMethod("readFields", (Class[]) null);
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
}
return Boolean.TRUE;
}

/**
Expand Down Expand Up @@ -2702,16 +2645,11 @@ private static class Callback {
final ObjectInputValidation obj;
final int priority;
Callback next;
@SuppressWarnings("removal")
final AccessControlContext acc;

Callback(ObjectInputValidation obj, int priority, Callback next,
@SuppressWarnings("removal") AccessControlContext acc)
{
Callback(ObjectInputValidation obj, int priority, Callback next) {
this.obj = obj;
this.priority = priority;
this.next = next;
this.acc = acc;
}
}

Expand Down Expand Up @@ -2740,12 +2678,10 @@ void register(ObjectInputValidation obj, int priority)
prev = cur;
cur = cur.next;
}
@SuppressWarnings("removal")
AccessControlContext acc = AccessController.getContext();
if (prev != null) {
prev.next = new Callback(obj, priority, cur, acc);
prev.next = new Callback(obj, priority, cur);
} else {
list = new Callback(obj, priority, list, acc);
list = new Callback(obj, priority, list);
}
}

Expand All @@ -2756,23 +2692,15 @@ void register(ObjectInputValidation obj, int priority)
* throws an InvalidObjectException, the callback process is terminated
* and the exception propagated upwards.
*/
@SuppressWarnings("removal")
void doCallbacks() throws InvalidObjectException {
try {
while (list != null) {
AccessController.doPrivileged(
new PrivilegedExceptionAction<Void>()
{
public Void run() throws InvalidObjectException {
list.obj.validateObject();
return null;
}
}, list.acc);
list.obj.validateObject();
list = list.next;
}
} catch (PrivilegedActionException ex) {
} catch (InvalidObjectException ex) {
list = null;
throw (InvalidObjectException) ex.getException();
throw ex;
}
}

Expand Down
Loading