diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/agent/EmbeddedPhosphorPatcher.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/agent/EmbeddedPhosphorPatcher.java index 8fd8cc995..78989c2bc 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/agent/EmbeddedPhosphorPatcher.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/agent/EmbeddedPhosphorPatcher.java @@ -1,6 +1,8 @@ package edu.columbia.cs.psl.phosphor.agent; +import edu.columbia.cs.psl.phosphor.runtime.mask.JdkUnsafeMasker; import org.objectweb.asm.ClassReader; +import org.objectweb.asm.Type; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; @@ -18,7 +20,7 @@ public byte[] patch(String name, byte[] content) { name = name.replace(".class", ""); if (ConfigurationEmbeddingCV.isApplicable(name)) { return PhosphorPatcher.apply(content, ConfigurationEmbeddingCV::new); - } else if (name.equals("edu/columbia/cs/psl/phosphor/runtime/RuntimeJDKInternalUnsafePropagator")) { + } else if (name.equals(Type.getInternalName(JdkUnsafeMasker.class))) { return PhosphorPatcher.apply(content, cv -> new UnsafePatchingCV(cv, patchUnsafeNames)); } else if (JdkUnsafeAdapterPatchingCV.isApplicable(name, patchUnsafeNames)) { return PhosphorPatcher.apply(content, JdkUnsafeAdapterPatchingCV::new); diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/mask/ReflectionHidingMV.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/mask/ReflectionHidingMV.java index 85b733957..779535b29 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/mask/ReflectionHidingMV.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/mask/ReflectionHidingMV.java @@ -4,7 +4,7 @@ import edu.columbia.cs.psl.phosphor.instrumenter.LocalVariableManager; import edu.columbia.cs.psl.phosphor.mask.MaskRegistry.MaskInfo; import edu.columbia.cs.psl.phosphor.runtime.*; -import edu.columbia.cs.psl.phosphor.runtime.mask.RuntimeJDKInternalUnsafePropagator; +import edu.columbia.cs.psl.phosphor.runtime.mask.JdkUnsafeMasker; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; @@ -102,7 +102,7 @@ private void maskUnsafe( } else if (shouldPatchUnsafe(name, descWithoutStackFrame)) { name = name.replace("Object", "Reference"); desc = "(L" + owner + ";" + desc.substring(1); - owner = Type.getInternalName(RuntimeJDKInternalUnsafePropagator.class); + owner = Type.getInternalName(JdkUnsafeMasker.class); super.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, false); } else { super.visitMethodInsn(opcode, owner, name, desc, isInterface); diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/JdkUnsafeAdapter.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/JdkUnsafeAdapter.java index fb25d87f1..f40b5f16a 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/JdkUnsafeAdapter.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/JdkUnsafeAdapter.java @@ -277,7 +277,7 @@ public void putDoubleVolatile(Object o, long offset, double x) { @Override public void putOrderedObject(Object o, long offset, Object x) { - unsafe.putObjectRelease(o, offset, x); + unsafe.putObjectVolatile(o, offset, x); } @Override @@ -292,11 +292,11 @@ public boolean compareAndSwapLong(Object o, long offset, long expected, long x) @Override public void putOrderedInt(Object o, long offset, int x) { - unsafe.putIntRelease(o, offset, x); + unsafe.putIntVolatile(o, offset, x); } @Override public void putOrderedLong(Object o, long offset, long x) { - unsafe.putLongRelease(o, offset, x); + unsafe.putLongVolatile(o, offset, x); } } \ No newline at end of file diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/RuntimeJDKInternalUnsafePropagator.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/JdkUnsafeMasker.java similarity index 99% rename from Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/RuntimeJDKInternalUnsafePropagator.java rename to Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/JdkUnsafeMasker.java index 8d0ea1385..a628b037c 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/RuntimeJDKInternalUnsafePropagator.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/mask/JdkUnsafeMasker.java @@ -14,12 +14,7 @@ /* Ensures that calls methods in UnsafeProxy that set or retrieve the value of a field of a Java heap object set and * retrieve both the original field and its associated taint field if it has one. */ -public class RuntimeJDKInternalUnsafePropagator { - - private RuntimeJDKInternalUnsafePropagator() { - // Prevents this class from being instantiated - } - +public class JdkUnsafeMasker { /* Used to disambiguate between a static field of a given type and an instance field of java.lang.Class */ static long LAST_INSTANCE_OFFSET_JAVA_LANG_CLASS = UnsafeProxy.INVALID_FIELD_OFFSET; @@ -206,6 +201,7 @@ public static void copyMemory(UnsafeProxy unsafe, long srcAddress, long destAddr unsafe.copyMemory(srcAddress, destAddress, length); } + @SuppressWarnings("unused") public static void copySwapMemory(UnsafeProxy unsafe, Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes, long elemSize, PhosphorStackFrame stackFrame) { if (srcBase instanceof TaggedArray) { @@ -217,6 +213,7 @@ public static void copySwapMemory(UnsafeProxy unsafe, Object srcBase, long srcOf unsafe.copySwapMemory(srcBase, srcOffset, destBase, destOffset, bytes, elemSize); } + @SuppressWarnings("unused") public static void copySwapMemory(UnsafeProxy unsafe, long srcAddress, long destAddress, long bytes, long elemSize, PhosphorStackFrame stackFrame) { unsafe.copySwapMemory(srcAddress, destAddress, bytes, elemSize); } @@ -1392,7 +1389,7 @@ public static Object getReference(UnsafeProxy unsafe, Object obj, long offset, P if (pair != null && pair.wrappedFieldOffset != UnsafeProxy.INVALID_FIELD_OFFSET) { offset = pair.wrappedFieldOffset; } - getTag(unsafe, obj, offset, phosphorStackFrame, RuntimeJDKInternalUnsafePropagator.SpecialAccessPolicy.NONE); + getTag(unsafe, obj, offset, phosphorStackFrame, SpecialAccessPolicy.NONE); return unsafe.getReference(obj, offset); } } @@ -1564,5 +1561,4 @@ public static void putDoubleRelease(UnsafeProxy unsafe, Object o, long offset, d public static void putBooleanRelease(UnsafeProxy unsafe, Object o, long offset, boolean x, PhosphorStackFrame phosphorStackFrame) { putBooleanVolatile(unsafe, o, offset, x, phosphorStackFrame); } - }