Commit e75dc036 authored by Eric W. Biederman's avatar Eric W. Biederman

signal: Fail sigqueueinfo if si_signo != sig

The kernel needs to validate that the contents of struct siginfo make
sense as siginfo is copied into the kernel, so that the proper union
members can be put in the appropriate locations.  The field si_signo
is a fundamental part of that validation.  As such changing the
contents of si_signo after the validation make no sense and can result
in nonsense values in the kernel.

As such simply fail if someone is silly enough to set si_signo out of
sync with the signal number passed to sigqueueinfo.

I don't expect a problem as glibc's sigqueue implementation sets
"si_signo = sig" and CRIU just returns to the kernel what the kernel
gave to it.

If there is some application that calls sigqueueinfo directly that has
a problem with this added sanity check we can revisit this when we see
what kind of crazy that application is doing.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 018303a9
...@@ -3306,7 +3306,8 @@ static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info) ...@@ -3306,7 +3306,8 @@ static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info)
(task_pid_vnr(current) != pid)) (task_pid_vnr(current) != pid))
return -EPERM; return -EPERM;
info->si_signo = sig; if (info->si_signo != sig)
return -EINVAL;
/* POSIX.1b doesn't mention process groups. */ /* POSIX.1b doesn't mention process groups. */
return kill_proc_info(sig, info, pid); return kill_proc_info(sig, info, pid);
...@@ -3354,7 +3355,8 @@ static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info) ...@@ -3354,7 +3355,8 @@ static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info)
(task_pid_vnr(current) != pid)) (task_pid_vnr(current) != pid))
return -EPERM; return -EPERM;
info->si_signo = sig; if (info->si_signo != sig)
return -EINVAL;
return do_send_specific(tgid, pid, sig, info); return do_send_specific(tgid, pid, sig, info);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment