Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openjdk/jdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 63eb4853
Choose a base ref
...
head repository: openjdk/jdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3f850839
Choose a head ref

Commits on Sep 30, 2024

  1. Initial load of JEP 486 implementation

    Co-authored-by: Sean Mullan <mullan@openjdk.org>
    Co-authored-by: Alan Bateman <alanb@openjdk.org>
    Co-authored-by: Weijun Wang <weijun@openjdk.org>
    Co-authored-by: Aleksei Efimov <aefimov@openjdk.org>
    Co-authored-by: Brian Burkhalter <bpb@openjdk.or>
    Co-authored-by: Daniel Fuchs <dfuchs@openjdk.org>
    Co-authored-by: Harshitha Onkar <honkar@openjdk.org>
    Co-authored-by: Joe Wang <joehw@openjdk.org>
    Co-authored-by: Jorn Vernee <jvernee@openjdk.org>
    Co-authored-by: Justin Lu <jlu@openjdk.org>
    Co-authored-by: Kevin Walls <kevinw@openjdk.org>>
    Co-authored-by: Lance Andersen <lancea@openjdk.org>
    Co-authored-by: Naoto Sato <naoto@openjdk.org>
    Co-authored-by: Roger Riggs <rriggs@openjdk.org>
    Co-authored-by: Brent Christian <bchristi@openjdk.org>
    AlanBateman committed Sep 30, 2024
    Copy the full SHA
    ef70021 View commit details

Commits on Oct 1, 2024

  1. Copy the full SHA
    591d3d6 View commit details
  2. Merge

    AlanBateman committed Oct 1, 2024
    Copy the full SHA
    781eecd View commit details
  3. Copy the full SHA
    4035376 View commit details
  4. Copy the full SHA
    6d2006d View commit details
  5. Fix whitespace.

    stuart-marks committed Oct 1, 2024
    Copy the full SHA
    6c325c2 View commit details
  6. Copy the full SHA
    463d46b View commit details

Commits on Oct 2, 2024

  1. Merge

    AlanBateman committed Oct 2, 2024
    Copy the full SHA
    439ed26 View commit details
  2. Remove vmTestbase/nsk/jvmti/AttachOnDemand/attach004/TestDescription.…

    …java, not useful without SM
    AlanBateman committed Oct 2, 2024
    Copy the full SHA
    53e06d0 View commit details
  3. Copy the full SHA
    9e1cec8 View commit details
  4. Remove leftover "@see java.lang.SecurityManager#checkSetFactory" from

    setInitialContextFactoryBuilder and setObjectFactoryBuilder methods in
    javax.naming.spi.NamingManager.
    seanjmullan committed Oct 2, 2024
    Copy the full SHA
    7cf5824 View commit details
  5. Copy the full SHA
    77b58bf View commit details

Commits on Oct 3, 2024

  1. Merge

    AlanBateman committed Oct 3, 2024
    Copy the full SHA
    b5f2ca3 View commit details
  2. Fix typo.

    seanjmullan committed Oct 3, 2024
    Copy the full SHA
    938737a View commit details
  3. Remove text about granting permission and add api note indicating

    permission cannot be used anymore to control access.
    seanjmullan committed Oct 3, 2024
    Copy the full SHA
    2612400 View commit details
  4. Copy the full SHA
    4688f78 View commit details
  5. Copy the full SHA
    34da8c7 View commit details
  6. Removed TestSecurityManagerChecks.java - this test was testing permis…

    …sion
    
    checks of the Class.getNestHost and getNestMembers methods, which no
    longer apply.
    seanjmullan committed Oct 3, 2024
    Copy the full SHA
    c62c4ad View commit details

Commits on Oct 4, 2024

  1. Copy the full SHA
    d8e15dd View commit details
  2. Merge

    AlanBateman committed Oct 4, 2024
    Copy the full SHA
    29c0bb2 View commit details
  3. Copy the full SHA
    23e0f09 View commit details
  4. Copy the full SHA
    bd27286 View commit details
  5. Copy the full SHA
    7f451ea View commit details
  6. Copy the full SHA
    c9ab253 View commit details
  7. Remove text about granting permissions to module from

    ModuleDescriptor.location().
    seanjmullan committed Oct 4, 2024
    Copy the full SHA
    36522ed View commit details
  8. Copy the full SHA
    c769f2d View commit details
  9. Copy the full SHA
    79b4b21 View commit details
  10. JDK-8003881: Prevent lambda implementing inner classes from allowing …

    …attacker to create new instances
    igraves committed Oct 4, 2024
    Copy the full SHA
    e46d99c View commit details
  11. JDK-8007035: deprecate public void SecurityManager.checkMemberAccess(…

    …Class<?> clazz, int which)
    igraves committed Oct 4, 2024
    Copy the full SHA
    422c489 View commit details

Commits on Oct 5, 2024

  1. Update copyright header

    AlanBateman committed Oct 5, 2024
    Copy the full SHA
    1f4be6f View commit details
  2. Merge

    AlanBateman committed Oct 5, 2024
    Copy the full SHA
    87f5a53 View commit details
  3. Copy the full SHA
    edcafbb View commit details
  4. Copy the full SHA
    dc6e158 View commit details
  5. Merge

    AlanBateman committed Oct 5, 2024
    Copy the full SHA
    09f5ffd View commit details
  6. Fix typo.

    seanjmullan committed Oct 5, 2024
    Copy the full SHA
    97c28c4 View commit details
  7. Copy the full SHA
    0fab6e0 View commit details
  8. Copy the full SHA
    901decf View commit details

Commits on Oct 7, 2024

  1. Remove @see SM.checkConnect

    AlanBateman committed Oct 7, 2024
    Copy the full SHA
    1702b47 View commit details
  2. Copy the full SHA
    a5629a2 View commit details
  3. Copy the full SHA
    cc4d56d View commit details
  4. Copy the full SHA
    2b4a91d View commit details
  5. Tweak deprecated text.

    seanjmullan committed Oct 7, 2024
    Copy the full SHA
    cf4adb9 View commit details
  6. Copy the full SHA
    1f3df69 View commit details
  7. Fix typo.

    seanjmullan committed Oct 7, 2024
    Copy the full SHA
    23bd997 View commit details
  8. Copy the full SHA
    ca96a40 View commit details
  9. Remove SM dependency from tools/doclint/tool/RunTest.java. Change test

    to execute DocLint main method in a separate process instead of using
    SM to catch System::exit.
    seanjmullan committed Oct 7, 2024
    Copy the full SHA
    425e72f View commit details
  10. Copy the full SHA
    d43e0a9 View commit details
  11. Tweak deprecation text.

    seanjmullan committed Oct 7, 2024
    Copy the full SHA
    281ceba View commit details
  12. Copy the full SHA
    9f17137 View commit details
  13. Copy the full SHA
    a598567 View commit details
10 changes: 2 additions & 8 deletions src/java.base/share/classes/java/io/ObjectInputFilter.java
Original file line number Diff line number Diff line change
@@ -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;
@@ -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;
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
@@ -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;
@@ -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
@@ -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");

/**
* 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);
}

/*
@@ -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();
@@ -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;
@@ -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;
}
@@ -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");
@@ -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;
}

/**
@@ -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;
}
}

@@ -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);
}
}

@@ -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;
}
}

82 changes: 17 additions & 65 deletions src/java.base/share/classes/java/io/ObjectOutputStream.java
Original file line number Diff line number Diff line change
@@ -26,8 +26,6 @@

package java.io;

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -224,11 +222,7 @@ protected Boolean computeValue(Class<?> type) {
* value of "sun.io.serialization.extendedDebugInfo" property,
* as true or false for extended information about exception's place
*/
@SuppressWarnings("removal")
private static final boolean extendedDebugInfo =
java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"sun.io.serialization.extendedDebugInfo")).booleanValue();
private static final boolean extendedDebugInfo = Boolean.getBoolean("sun.io.serialization.extendedDebugInfo");

/**
* Creates an ObjectOutputStream that writes to the specified OutputStream.
@@ -247,7 +241,6 @@ protected Boolean computeValue(Class<?> type) {
*/
@SuppressWarnings("this-escape")
public ObjectOutputStream(OutputStream out) throws IOException {
verifySubclass();
bout = new BlockDataOutputStream(out);
handles = new HandleTable(10, (float) 3.00);
subs = new ReplaceTable(10, (float) 3.00);
@@ -269,11 +262,6 @@ public ObjectOutputStream(OutputStream out) throws IOException {
* @throws IOException if an I/O error occurs while creating this stream
*/
protected ObjectOutputStream() throws IOException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
}
bout = null;
handles = null;
subs = null;
@@ -595,13 +583,6 @@ protected boolean enableReplaceObject(boolean enable) {
if (enable == enableReplace) {
return enable;
}
if (enable) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SUBSTITUTION_PERMISSION);
}
}
enableReplace = enable;
return !enableReplace;
}
@@ -1022,58 +1003,29 @@ void writeTypeString(String str) throws IOException {
}
}

/**
* 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 == ObjectOutputStream.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<>() {
public Boolean run() {
for (Class<?> cl = subcl;
cl != ObjectOutputStream.class;
cl = cl.getSuperclass())
{
try {
cl.getDeclaredMethod(
"writeUnshared", new Class<?>[] { Object.class });
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
try {
cl.getDeclaredMethod("putFields", (Class<?>[]) null);
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
}
return Boolean.TRUE;
}
for (Class<?> cl = subcl;
cl != ObjectOutputStream.class;
cl = cl.getSuperclass())
{
try {
cl.getDeclaredMethod(
"writeUnshared", new Class<?>[] { Object.class });
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
);
try {
cl.getDeclaredMethod("putFields", (Class<?>[]) null);
return Boolean.FALSE;
} catch (NoSuchMethodException ex) {
}
}
return Boolean.TRUE;
}

/**
Loading