um: Fetch registers only for signals which need them
authorAnton Ivanov <anton.ivanov@cambridgegreys.com>
Tue, 10 Nov 2020 13:02:21 +0000 (13:02 +0000)
committerRichard Weinberger <richard@nod.at>
Sun, 13 Dec 2020 21:38:06 +0000 (22:38 +0100)
UML userspace fetches siginfo and passes it to signal handlers
in UML. This is needed only for some of the signals, because
key handlers like SIGIO make no use of this variable.

Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/os-Linux/skas/process.c

index 4fb877b99ddedc6b4132bf3938bd80a1e2b285b6..0621d521208e407342a4e1e05cf29190ae509140 100644 (file)
@@ -400,7 +400,20 @@ void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
                if (WIFSTOPPED(status)) {
                        int sig = WSTOPSIG(status);
 
-                       ptrace(PTRACE_GETSIGINFO, pid, 0, (struct siginfo *)&si);
+                       /* These signal handlers need the si argument.
+                        * The SIGIO and SIGALARM handlers which constitute the
+                        * majority of invocations, do not use it.
+                        */
+                       switch (sig) {
+                       case SIGSEGV:
+                       case SIGTRAP:
+                       case SIGILL:
+                       case SIGBUS:
+                       case SIGFPE:
+                       case SIGWINCH:
+                               ptrace(PTRACE_GETSIGINFO, pid, 0, (struct siginfo *)&si);
+                               break;
+                       }
 
                        switch (sig) {
                        case SIGSEGV: