[Bug 225105] Linux static golang binaries crash at startup

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Aug 27 07:45:08 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225105

Yanko Yankulov <yanko.yankulov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yanko.yankulov at gmail.com

--- Comment #11 from Yanko Yankulov <yanko.yankulov at gmail.com> ---
Hi guys,


Hit this a few weeks ago haven't notice the ticket, the sysarch call will try
to load the arguments from userspace and fail as they are on the kernel stack.
A working (but ugly) solution is to duplicate the code in linux_machdep:

--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -240,10 +240,14 @@ linux_arch_prctl(struct thread *td, struct
linux_arch_prctl_args *args)
                        error = EPERM;
                break;
        case LINUX_ARCH_SET_FS:
-               bsd_args.op = AMD64_SET_FSBASE;
-               bsd_args.parms = (void *)args->addr;
-               error = sysarch(td, &bsd_args);
-               if (error == EINVAL)
+               if (args->addr < VM_MAXUSER_ADDRESS) {
+                       struct pcb *pcb = curthread->td_pcb;
+                       set_pcb_flags(pcb, PCB_FULL_IRET);
+                       pcb->pcb_fsbase = args->addr;
+                       td->td_frame->tf_fs = _ufssel;
+                       error = 0;
+               }
+               else
                        error = EPERM;

A better solution will be to change sysarch to accept addition parameter about
the location of the memory, but haven't have the time to explore this path yet.

Hope this helps.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-emulation mailing list