lkml.org 
[lkml]   [2022]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 09/16] ptrace: In ptrace_setsiginfo deal with invalid si_signo
    If the tracer calls PTRACE_SETSIGINFO it only has an effect if the
    tracee is stopped in ptrace_signal.

    When one of PTRACE_DETACH, PTRACE_SINGLESTEP, PTRACE_SINGLEBLOCK,
    PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, PTRACE_SYSCALL, or
    PTRACE_CONT pass in a signel number to continue with the kernel
    validates that signal number and the ptrace_signal verifies the signal
    number matches the si_signo, before the siginfo is used.

    As the signal number to continue with is verified to be a valid signal
    number the signal number in si_signo must be a valid signal number.

    Make this obvious and avoid needing checks later by immediately
    clearing siginfo if si_signo is not valid.

    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    ---
    kernel/ptrace.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)

    diff --git a/kernel/ptrace.c b/kernel/ptrace.c
    index a24eed725cec..a0a07d140751 100644
    --- a/kernel/ptrace.c
    +++ b/kernel/ptrace.c
    @@ -716,7 +716,9 @@ static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *
    if (unlikely(!child->last_siginfo))
    return -EINVAL;

    - copy_siginfo(child->last_siginfo, info);
    + clear_siginfo(child->last_siginfo);
    + if (valid_signal(info->si_signo))
    + copy_siginfo(child->last_siginfo, info);
    return 0;
    }

    --
    2.35.3
    \
     
     \ /
      Last update: 2022-05-19 00:55    [W:4.040 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site