On Sun, 2021-04-18 at 01:56 -0500, YiFei Zhu wrote: > On Sat, Apr 17, 2021 at 11:56 PM YiFei Zhu > wrote: > >   * um on um x86_64: I'm having trouble testing um within um, getting > > a weird error ("start_userspace : expected SIGSTOP, got status = > > 2943" > > when starting init, might try to debug later), but the code in > > handle_signal also aligns the stack. > > Figured this one out. The inner um, in userspace_tramp, is trying to > mmap the syscall stub to the same syscall stub at the same location as > the outer um, and that fails with ENOMEM. In theory, this would cause > the printk of "mapping mmap stub at ... failed, errno = ..." to occur, > but because: > * call stack: vprintk_store -> printk_caller_id -> in_task -> in_nmi > -> nmi_count -> preempt_count -> current_thread_info > * um's current_thread_info is at the current stack pointer & mask, > hence it is often not valid when on small temporary stacks. > Therefore, userspace_tramp can't printk. > > I'm wondering, is this issue of printk being broken in userspace_tramp > an issue worth fixing? Has there been prior discussions on it? Yeah, printk is only usable from kernel threads. So in other cases logging should happen directly. But do note that os_info with its current glibc printf implementation seems to also create issues sometimes as it may require more stack than available. In my seccomp patchset, I added a few patches to fix related issues, see https://patchwork.ozlabs.org/project/linux-um/list/?series=231980 specifically * [06/27] um: Don't use vfprintf() for os_info() * [07/27] um: Do not use printk in SIGWINCH helper thread * [09/27] um: Do not use printk in userspace trampoline Benjamin