From b6dbde9f9f754fc44d073e7e094da4fead8de992 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Sun, 25 Jan 2026 19:52:33 +0900 Subject: [PATCH] Update comments in findTargetProcessTmpDirectory() --- .../sun/tools/attach/VirtualMachineImpl.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java index cd6e6e45e34..4a1cd3aba78 100644 --- a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java @@ -258,20 +258,22 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { final var tmpOnProcPidRoot = PROC.resolve(Long.toString(pid)).resolve(ROOT_TMP); /* We need to handle at least 4 different cases: - * 1. Caller and target processes share PID namespace and root filesystem (host to host or container to - * container with both /tmp mounted between containers). - * 2. Caller and target processes share PID namespace and root filesystem but the target process has elevated - * privileges (host to host). - * 3. Caller and target processes share PID namespace but NOT root filesystem (container to container). - * 4. Caller and target processes share neither PID namespace nor root filesystem (host to container) + * 1. Caller and target processes share PID namespace and root + * filesystem (host to host or container to container with both /tmp + * mounted between containers). + * 2. Caller and target processes share PID namespace and root + * filesystem but the target process has elevated privileges + * (host to host). + * 3. Caller and target processes share PID namespace but NOT root + * filesystem (container to container). + * 4. Caller and target processes share neither PID namespace nor root + * filesystem (host to container) * - * if target is elevated, we cant use /proc//... so we have to fallback to /tmp, but that may not be shared - * with the target/attachee process, so we should check whether /tmp on both is same. This method would throw - * AttachNotSupportedException if they are different because we cannot make a connection with target VM. - * - * In addition, we can also check the target pid's signal masks to see if it catches SIGQUIT and only do so if in - * fact it does ... this reduces the risk of killing an innocent process in the current ns as opposed to - * attaching to the actual target JVM ... c.f: checkCatchesAndSendQuitTo() below. + * if target is elevated, we cant use /proc//... so we have to + * fallback to /tmp, but that may not be shared with the target/attachee + * process, so we should check whether /tmp on both is same. This method + * would throw AttachOperationFailedException if they are different + * because we cannot make a connection with target VM. */ try { @@ -303,7 +305,8 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { // exception should not happen. throw new AssertionError("Unexpected exception", e); } catch (MonitorException e) { - // Other exceptions (happened at MonitoredHost) would be wrapped with AttachOperationFailedException + // Other exceptions (happened at MonitoredHost) would be wrapped + // with AttachOperationFailedException. throw new AttachOperationFailedException("Unable to find target proces", e); } }