mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
UPSTREAM: signal: don't silently convert SI_USER signals to non-current pidfd
The current sys_pidfd_send_signal() silently turns signals with explicit SI_USER context that are sent to non-current tasks into signals with kernel-generated siginfo. This is unlike do_rt_sigqueueinfo(), which returns -EPERM in this case. If a user actually wants to send a signal with kernel-provided siginfo, they can do that with pidfd_send_signal(pidfd, sig, NULL, 0); so allowing this case is unnecessary. Instead of silently replacing the siginfo, just bail out with an error; this is consistent with other interfaces and avoids special-casing behavior based on security checks. Fixes:3eb39f4793("signal: add pidfd_send_signal() syscall") Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Christian Brauner <christian@brauner.io> (cherry picked from commit556a888a14) Bug: 135608568 Test: test program using syscall(__NR_pidfd_send_signal,..) to send SIGKILL Change-Id: I004452c19c50296730a2c6852a5ef47abd69d819 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
committed by
Joel Fernandes (Google)
parent
1f27ef8d9b
commit
74c14d6081
@@ -3381,16 +3381,11 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig,
|
||||
if (unlikely(sig != kinfo.si_signo))
|
||||
goto err;
|
||||
|
||||
/* Only allow sending arbitrary signals to yourself. */
|
||||
ret = -EPERM;
|
||||
if ((task_pid(current) != pid) &&
|
||||
(kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL)) {
|
||||
/* Only allow sending arbitrary signals to yourself. */
|
||||
ret = -EPERM;
|
||||
if (kinfo.si_code != SI_USER)
|
||||
goto err;
|
||||
|
||||
/* Turn this into a regular kill signal. */
|
||||
prepare_kill_siginfo(sig, &kinfo);
|
||||
}
|
||||
(kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL))
|
||||
goto err;
|
||||
} else {
|
||||
prepare_kill_siginfo(sig, &kinfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user