SecBSD's official ports repository

This commit is contained in:
purplerain 2023-08-16 22:26:55 +00:00
commit 2c0afcbbf3
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
64331 changed files with 5339189 additions and 0 deletions

View file

@ -0,0 +1,18 @@
Index: make/autoconf/flags-ldflags.m4
--- make/autoconf/flags-ldflags.m4.orig
+++ make/autoconf/flags-ldflags.m4
@@ -127,12 +127,12 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER],
if test "x$OPENJDK_TARGET_OS_ENV" = xbsd.openbsd; then
AC_MSG_CHECKING([if ld requires -z wxneeded])
PUSHED_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS -Wl,-z,wxneeded"
+ LDFLAGS="$LDFLAGS -Wl,-z,wxneeded -Wl,-z,nobtcfi"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { }]])],
[
if $READELF -l conftest$ac_exeext | $GREP WXNEED > /dev/null; then
AC_MSG_RESULT([yes])
- OS_LDFLAGS="-Wl,-z,wxneeded"
+ OS_LDFLAGS="-Wl,-z,wxneeded -Wl,-z,nobtcfi"
else
AC_MSG_RESULT([no])
fi

View file

@ -0,0 +1,18 @@
Keep full bin/lib with debug in debuginfo file so it can be restored
later in post-build. This results in jmod's without debuginfo so we
get the debug package without bloating the size of the jdk package.
Index: make/common/NativeCompilation.gmk
--- make/common/NativeCompilation.gmk.orig
+++ make/common/NativeCompilation.gmk
@@ -1003,9 +1003,7 @@ define SetupNativeCompilationBody
# Setup the command line creating debuginfo files, to be run after linking.
# It cannot be run separately since it updates the original target file
$1_CREATE_DEBUGINFO_CMDS := \
- $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES) $$(NEWLINE) \
- $(CD) $$($1_OUTPUT_DIR) && \
- $$($1_OBJCOPY) --add-gnu-debuglink=$$($1_DEBUGINFO_FILES) $$($1_TARGET)
+ $(CP) $$($1_TARGET) $$($1_DEBUGINFO_FILES)
else ifeq ($(OPENJDK_TARGET_OS), aix)
# AIX does not provide the equivalent of OBJCOPY to extract debug symbols,

View file

@ -0,0 +1,11 @@
Index: src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp
--- src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp.orig
+++ src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp
@@ -1321,7 +1321,6 @@ address TemplateInterpreterGenerator::generate_native_
__ ldr(r10, Address(rmethod, Method::native_function_offset()));
address unsatisfied = (SharedRuntime::native_method_throw_unsatisfied_link_error_entry());
__ mov(rscratch2, unsatisfied);
- __ ldr(rscratch2, rscratch2);
__ cmp(r10, rscratch2);
__ br(Assembler::NE, L);
__ call_VM(noreg,

View file

@ -0,0 +1,18 @@
Add support for detecting the primordial thread
Index: src/hotspot/os/bsd/os_bsd.cpp
--- src/hotspot/os/bsd/os_bsd.cpp.orig
+++ src/hotspot/os/bsd/os_bsd.cpp
@@ -4407,6 +4407,12 @@ static void current_stack_region(address * bottom, siz
os::current_stack_pointer() < *bottom + *size, "just checking");
}
+#ifdef __OpenBSD__
+bool os::is_primordial_thread() {
+ return (pthread_main_np() == 1);
+}
+#endif
+
address os::current_stack_base() {
address bottom;
size_t size;

View file

@ -0,0 +1,14 @@
Add support for detecting the primordial thread
Index: src/hotspot/share/runtime/os.hpp
--- src/hotspot/share/runtime/os.hpp.orig
+++ src/hotspot/share/runtime/os.hpp
@@ -508,7 +508,7 @@ class os: AllStatic {
// need special-case handling of the primordial thread if it attaches
// to the VM.
static bool is_primordial_thread(void)
-#if defined(_WINDOWS) || defined(BSD)
+#if defined(_WINDOWS) || (defined(BSD) && !defined(__OpenBSD__))
// No way to identify the primordial thread.
{ return false; }
#else

View file

@ -0,0 +1,19 @@
Disable stack guarding on the primordial thread because its protections
are immutable. Note this will interfere with the primordial thread throwing
StackOverflowError exceptions.
Index: src/hotspot/share/runtime/thread.cpp
--- src/hotspot/share/runtime/thread.cpp.orig
+++ src/hotspot/share/runtime/thread.cpp
@@ -2608,7 +2608,11 @@ size_t JavaThread::_stack_shadow_zone_size = 0;
void JavaThread::create_stack_guard_pages() {
if (!os::uses_stack_guard_pages() ||
_stack_guard_state != stack_guard_unused ||
+#ifdef __OpenBSD__
+ (os::is_primordial_thread())) {
+#else
(DisablePrimordialThreadGuardPages && os::is_primordial_thread())) {
+#endif
log_info(os, thread)("Stack guard page creation for thread "
UINTX_FORMAT " disabled", os::current_thread_id());
return;

View file

@ -0,0 +1,12 @@
Index: src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
--- src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java.orig
+++ src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
@@ -59,7 +59,7 @@ abstract class AbstractPlainDatagramSocketImpl extends
/**
* flag set if the native connect() call not to be used
*/
- private static final boolean connectDisabled = os.contains("OS X");
+ private static final boolean connectDisabled = os.contains("OS X") || os.equals("OpenBSD");
/**
* Load net library into runtime.

View file

@ -0,0 +1,14 @@
Start using waitid(2)
Index: src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
--- src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c.orig
+++ src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
@@ -259,7 +259,7 @@ Java_java_lang_ProcessHandleImpl_waitForProcessExit0(J
return status;
}
} else {
-#if defined(__OpenBSD__)
+#if defined(__OpenBSD__) && OpenBSD < 202304
return os_waitForProcessExitNoReap(pid);
#else
/*

View file

@ -0,0 +1,24 @@
Start using waitid(2)
Index: src/java.base/unix/native/libjava/ProcessHandleImpl_unix.h
--- src/java.base/unix/native/libjava/ProcessHandleImpl_unix.h.orig
+++ src/java.base/unix/native/libjava/ProcessHandleImpl_unix.h
@@ -25,6 +25,10 @@
#include <sys/types.h>
+#ifdef __OpenBSD__
+ #include <sys/param.h>
+#endif
+
/*
* Declaration of ProcessHandleImpl functions common on all Unix platforms.
* 'unix_' functions have a single implementation in ProcessHandleImpl_unix.c
@@ -75,6 +79,6 @@ extern void unix_fillArgArray(JNIEnv *env, jobject jin
extern void os_initNative(JNIEnv *env, jclass clazz);
-#if defined(__OpenBSD__)
+#if defined(__OpenBSD__) && OpenBSD < 202304
extern int os_waitForProcessExitNoReap(pid_t pid);
#endif

View file

@ -0,0 +1,12 @@
Index: src/java.desktop/share/classes/sun/print/PSPrinterJob.java
--- src/java.desktop/share/classes/sun/print/PSPrinterJob.java.orig
+++ src/java.desktop/share/classes/sun/print/PSPrinterJob.java
@@ -1620,7 +1620,7 @@ public class PSPrinterJob extends RasterPrinterJob {
String osname = System.getProperty("os.name");
if (osname.equals("Linux") || osname.contains("OS X") || osname.endsWith("BSD")) {
- String lprPath = "/usr/bin/lpr";
+ String lprPath = (osname.equals("OpenBSD")) ? "/usr/local/bin/lpr" : "/usr/bin/lpr";
if (osname.equals("FreeBSD")) {
final PrintService pservice = getPrintService();
Boolean isIPPPrinter = java.security.AccessController.doPrivileged(