tgkill: Fix argument validatation

Formerly, if tgid is specified as -1, tgkill() was equivalent to tkill().
Now it is treated as an error EINVAL.

Change-Id: I47bc75d439662a36dc6167c4446a5277422de507
Refs: 1380
This commit is contained in:
Ken Sato
2020-07-02 10:56:26 +09:00
committed by Masamichi Takagi
parent 58106d791a
commit ebc91cea0e
6 changed files with 136 additions and 6 deletions

View File

@@ -3240,7 +3240,6 @@ SYSCALL_DECLARE(kill)
return error;
}
// see linux-2.6.34.13/kernel/signal.c
SYSCALL_DECLARE(tgkill)
{
int tgid = ihk_mc_syscall_arg0(ctx);
@@ -3249,16 +3248,15 @@ SYSCALL_DECLARE(tgkill)
struct thread *thread = cpu_local_var(current);
struct siginfo info;
if (tgid <= 0 || tid <= 0) {
return -EINVAL;
}
memset(&info, '\0', sizeof info);
info.si_signo = sig;
info.si_code = SI_TKILL;
info._sifields._kill.si_pid = thread->proc->pid;
if(tid <= 0)
return -EINVAL;
if(tgid <= 0 && tgid != -1)
return -EINVAL;
return do_kill(thread, tgid, tid, sig, &info, 0);
}