From e088121b3a81a590f9c6e00db203356c6431720c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 7 Nov 2018 10:48:44 +0100 Subject: [PATCH] Fix sys$sigaction() to return the old action metadata if requested. --- Kernel/Makefile | 2 +- Kernel/Process.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Kernel/Makefile b/Kernel/Makefile index 963aa72b5b..d1966c5bd0 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -59,7 +59,7 @@ WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings FLAVOR_FLAGS = -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -SUGGEST_FLAGS = -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override +SUGGEST_FLAGS = -Wsuggest-attribute=noreturn -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override DEFINES = -DSERENITY -DKERNEL -DSANITIZE_PTRS diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 6137ad2441..a46e3ce505 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1564,6 +1564,12 @@ int Process::sys$sigaction(int signum, const Unix::sigaction* act, Unix::sigacti VALIDATE_USER_READ(act, sizeof(Unix::sigaction)); InterruptDisabler disabler; // FIXME: This should use a narrower lock. auto& action = m_signal_action_data[signum]; + if (old_act) { + VALIDATE_USER_WRITE(old_act, sizeof(Unix::sigaction)); + old_act->sa_flags = action.flags; + old_act->sa_restorer = (decltype(old_act->sa_restorer))action.restorer.get(); + old_act->sa_sigaction = (decltype(old_act->sa_sigaction))action.handler_or_sigaction.get(); + } action.restorer = LinearAddress((dword)act->sa_restorer); action.flags = act->sa_flags; action.handler_or_sigaction = LinearAddress((dword)act->sa_sigaction);