On Sun, 08 Dec 2024 19:15:37 +0900, Hajime Tazaki wrote: > > This commit updates the behavior of signal handling under !MMU > environment. 1) the stack preparation for the signal handlers and > 2) restoration of stack after rt_sigreturn(2) syscall. Those are needed > as the stack usage on vfork(2) syscall is different. > > It also adds the follow up routine for SIGSEGV as a signal delivery runs > in the same stack frame while we have to avoid endless SIGSEGV. (snip) > diff --git a/arch/x86/um/nommu/signal.c b/arch/x86/um/nommu/signal.c > new file mode 100644 > index 000000000000..a94e9b86273a > --- /dev/null > +++ b/arch/x86/um/nommu/signal.c > @@ -0,0 +1,43 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#include <linux/syscalls.h> > +#include <linux/kernel.h> > +#include <asm/sigframe.h> > + > +#include <sysdep/signal.h> > + > +int arch_setup_signal_stack_si(struct rt_sigframe __user **frame, > + struct ksignal *ksig) > +{ > + int err = 0; > + > + /* > + * we need to push handler address at top of stack, as > + * __kernel_vsyscall, called after this returns with ret with > + * stack contents, thus push the handler here. > + */ > + *frame = (struct rt_sigframe __user *) ((unsigned long) *frame - > + sizeof(unsigned long)); > + err |= __put_user((unsigned long)ksig->ka.sa.sa_handler, > + (unsigned long *)*frame); > + > + return err;
this has a serious issue to handle signals. I also found that manipulation of stack pointer makes the code cryptic.. I will clean up those parts in the next version. -- Hajime