Bug 506930 - valgrind allows SIGKILL being reset to SIG_DFL
Summary: valgrind allows SIGKILL being reset to SIG_DFL
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: 3.25.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks: 506971
  Show dependency treegraph
 
Reported: 2025-07-11 22:56 UTC by Mark Wielaard
Modified: 2025-07-14 21:37 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2025-07-11 22:56:16 UTC
LTP signal01 testcase fails with:
signal01.c:56: TFAIL: (long)signal(SIGKILL, tc->sighandler) succeeded
Should fail with EINVAL (SIGKILL can not be reset to default)

Seems that do_sys_sigaction explicitly allows that.
Not sure why, fix might be as simple as:

diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c
index f0e6b8e7cf2e..67893d473603 100644
--- a/coregrind/m_signals.c
+++ b/coregrind/m_signals.c
@@ -1319,8 +1319,7 @@ SysRes VG_(do_sys_sigaction) ( Int signo,

    /* Reject attempts to set a handler (or set ignore) for SIGKILL. */
    if ( (signo == VKI_SIGKILL || signo == VKI_SIGSTOP)
-       && new_act
-       && new_act->ksa_handler != VKI_SIG_DFL)
+       && new_act )
       goto bad_sigkill_or_sigstop;

    /* If the client supplied non-NULL old_act, copy the relevant SCSS
Comment 1 Mark Wielaard 2025-07-14 21:37:55 UTC
commit 806abab0557a53546d9498926f699fd679b9f0f1
Author: Mark Wielaard <mark@klomp.org>
Date:   Mon Jul 14 23:23:23 2025 +0200

    Reject any attempt to set the handler for SIGKILL/STOP
    
    Even though resetting SIGKILL or SIGSTOP to SIG_DFL would be a noop it
    isn't allowed. Just always return EINVAL if an attempt is made to set
    the signal handler for SIGKILL or SIGSTOP. There is an LTP test for
    this signal01.
    
    https://bugs.kde.org/show_bug.cgi?id=506930