Wed, 07 Feb 2018 13:57:42 -0800
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Wed Feb 07 13:41:55 2018 -0800 1.2 +++ b/.hgtags Wed Feb 07 13:57:42 2018 -0800 1.3 @@ -1132,6 +1132,8 @@ 1.4 69aec2ca5d905dde1d0f29a89076d02a531808a3 jdk8u162-b12 1.5 caac74fe3cfa9a8c859c28c97d1046a58252af27 jdk8u162-b31 1.6 c9b7abadf150328d2187de05b9e8a9cba2486e47 jdk8u162-b32 1.7 +e8041f2ec96eb6a41307732e6cf6ed90901438ae jdk8u162-b33 1.8 +bf2e8b1e8e8e6bc1f9b9475de54ba0329a6b24b1 jdk8u162-b34 1.9 a17bab9405474602b18cd62e060a09b17d6413ac jdk8u171-b00 1.10 ebfd57cc21e6b7f0c22b17c666b6b28c9340e207 jdk8u171-b01 1.11 1acd7c1b80241def8fac90f70b0df16356adad47 jdk8u171-b02
2.1 --- a/agent/src/os/linux/Makefile Wed Feb 07 13:41:55 2018 -0800 2.2 +++ b/agent/src/os/linux/Makefile Wed Feb 07 13:57:42 2018 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 # 2.5 -# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 2.6 +# Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. 2.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 # 2.9 # This code is free software; you can redistribute it and/or modify it 2.10 @@ -76,6 +76,9 @@ 2.11 endif 2.12 LFLAGS_LIBSA += $(LDFLAGS_HASH_STYLE) 2.13 2.14 +LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack" 2.15 +LFLAGS_LIBSA += $(LDFLAGS_NO_EXEC_STACK) 2.16 + 2.17 $(LIBSA): $(ARCH) $(OBJS) mapfile 2.18 $(GCC) -shared $(LFLAGS_LIBSA) -o $(LIBSA) $(OBJS) $(LIBS) 2.19
3.1 --- a/make/linux/makefiles/gcc.make Wed Feb 07 13:41:55 2018 -0800 3.2 +++ b/make/linux/makefiles/gcc.make Wed Feb 07 13:57:42 2018 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 # 3.5 -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. 3.6 +# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. 3.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 # 3.9 # This code is free software; you can redistribute it and/or modify it 3.10 @@ -303,6 +303,8 @@ 3.11 3.12 LFLAGS += $(LDFLAGS_HASH_STYLE) 3.13 3.14 +LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack" 3.15 + 3.16 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. 3.17 MAPFLAG = -Xlinker --version-script=FILENAME 3.18
4.1 --- a/make/linux/makefiles/jsig.make Wed Feb 07 13:41:55 2018 -0800 4.2 +++ b/make/linux/makefiles/jsig.make Wed Feb 07 13:57:42 2018 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 # 4.5 -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 4.6 +# Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. 4.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 # 4.9 # This code is free software; you can redistribute it and/or modify it 4.10 @@ -44,7 +44,7 @@ 4.11 # cause problems with interposing. See CR: 6466665 4.12 # LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE)) 4.13 4.14 -LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE) 4.15 +LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE) $(LDFLAGS_NO_EXEC_STACK) 4.16 4.17 # DEBUG_BINARIES overrides everything, use full -g debug information 4.18 ifeq ($(DEBUG_BINARIES), true)
5.1 --- a/src/share/vm/prims/whitebox.cpp Wed Feb 07 13:41:55 2018 -0800 5.2 +++ b/src/share/vm/prims/whitebox.cpp Wed Feb 07 13:57:42 2018 -0800 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -158,6 +158,9 @@ 5.11 } 5.12 WB_END 5.13 5.14 +#ifdef LINUX 5.15 +#include "utilities/elfFile.hpp" 5.16 +#endif 5.17 5.18 WB_ENTRY(jlong, WB_GetCompressedOopsMaxHeapSize(JNIEnv* env, jobject o)) { 5.19 return (jlong)Arguments::max_heap_for_compressed_oops(); 5.20 @@ -1010,6 +1013,21 @@ 5.21 } 5.22 } 5.23 5.24 +// Checks that the library libfile has the noexecstack bit set. 5.25 +WB_ENTRY(jboolean, WB_CheckLibSpecifiesNoexecstack(JNIEnv* env, jobject o, jstring libfile)) 5.26 + jboolean ret = false; 5.27 +#ifdef LINUX 5.28 + // Can't be in VM when we call JNI. 5.29 + ThreadToNativeFromVM ttnfv(thread); 5.30 + const char* lf = env->GetStringUTFChars(libfile, NULL); 5.31 + CHECK_JNI_EXCEPTION_(env, 0); 5.32 + ElfFile ef(lf); 5.33 + ret = (jboolean) ef.specifies_noexecstack(); 5.34 + env->ReleaseStringUTFChars(libfile, lf); 5.35 +#endif 5.36 + return ret; 5.37 +WB_END 5.38 + 5.39 #define CC (char*) 5.40 5.41 static JNINativeMethod methods[] = { 5.42 @@ -1121,6 +1139,8 @@ 5.43 (void*)&WB_GetNMethod }, 5.44 {CC"isMonitorInflated", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated }, 5.45 {CC"forceSafepoint", CC"()V", (void*)&WB_ForceSafepoint }, 5.46 + {CC"checkLibSpecifiesNoexecstack", CC"(Ljava/lang/String;)Z", 5.47 + (void*)&WB_CheckLibSpecifiesNoexecstack}, 5.48 }; 5.49 5.50 #undef CC
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/runtime/execstack/TestCheckJDK.java Wed Feb 07 13:57:42 2018 -0800 6.3 @@ -0,0 +1,67 @@ 6.4 +/* 6.5 + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. 6.11 + * 6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.15 + * version 2 for more details (a copy is included in the LICENSE file that 6.16 + * accompanied this code). 6.17 + * 6.18 + * You should have received a copy of the GNU General Public License version 6.19 + * 2 along with this work; if not, write to the Free Software Foundation, 6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.21 + * 6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.23 + * or visit www.oracle.com if you need additional information or have any 6.24 + * questions. 6.25 + */ 6.26 + 6.27 +/** 6.28 + * @test Testexecstack.java 6.29 + * @summary Searches for all libraries in test VM and checks that they 6.30 + * have the noexecstack bit set. 6.31 + * @requires (os.family == "linux") 6.32 + * @library /testlibrary /testlibrary/whitebox 6.33 + * @build sun.hotspot.WhiteBox 6.34 + * @run driver ClassFileInstaller sun.hotspot.WhiteBox 6.35 + * sun.hotspot.WhiteBox$WhiteBoxPermission 6.36 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 6.37 + * TestCheckJDK 6.38 + */ 6.39 + 6.40 +import com.oracle.java.testlibrary.Asserts; 6.41 +import sun.hotspot.WhiteBox; 6.42 + 6.43 +import java.nio.file.Files; 6.44 +import java.nio.file.Path; 6.45 +import java.nio.file.Paths; 6.46 + 6.47 +public class TestCheckJDK { 6.48 + static boolean testPassed = true; 6.49 + private static final WhiteBox WB = WhiteBox.getWhiteBox(); 6.50 + 6.51 + static void checkExecStack(Path file) { 6.52 + String filename = file.toString(); 6.53 + if (filename.endsWith(".so")) { 6.54 + if (!WB.checkLibSpecifiesNoexecstack(filename)) { 6.55 + System.out.println("Library does not have the noexecstack bit set: " + filename); 6.56 + testPassed = false; 6.57 + } 6.58 + } 6.59 + } 6.60 + 6.61 + public static void main(String[] args) throws Throwable { 6.62 + String vmInstallDir = System.getProperty("java.home"); 6.63 + 6.64 + Files.walk(Paths.get(vmInstallDir)).filter(Files::isRegularFile).forEach(TestCheckJDK::checkExecStack); 6.65 + 6.66 + Asserts.assertTrue(testPassed, 6.67 + "The tested VM contains libs that don't have the noexecstack " + 6.68 + "bit set. They must be linked with -z,noexecstack."); 6.69 + } 6.70 +}
7.1 --- a/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Wed Feb 07 13:41:55 2018 -0800 7.2 +++ b/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java Wed Feb 07 13:57:42 2018 -0800 7.3 @@ -1,5 +1,5 @@ 7.4 /* 7.5 - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. 7.6 + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. 7.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.8 * 7.9 * This code is free software; you can redistribute it and/or modify it 7.10 @@ -235,4 +235,7 @@ 7.11 7.12 // Class Data Sharing 7.13 public native boolean isSharedClass(Class<?> c); 7.14 + 7.15 + // Returns true on linux if library has the noexecstack flag set. 7.16 + public native boolean checkLibSpecifiesNoexecstack(String libfilename); 7.17 }