From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrey Vagin Subject: [PATCH 1/3] signal: allow to send any siginfo to itself Date: Mon, 14 Jan 2013 20:53:53 +0400 Message-ID: <1358182435-19245-2-git-send-email-avagin@openvz.org> References: <1358182435-19245-1-git-send-email-avagin@openvz.org> Cc: criu@openvz.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Andrey Vagin , Oleg Nesterov , Serge Hallyn , Andrew Morton , "Eric W. Biederman" , Al Viro , Michael Kerrisk , Pavel Emelyanov , Cyrill Gorcunov To: linux-kernel@vger.kernel.org Return-path: In-Reply-To: <1358182435-19245-1-git-send-email-avagin@openvz.org> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org A kernel prevents of sending siginfo with positive si_code, because these codes is reserved for kernel. I think we can allow to send any siginfo to itself. This operation should not be dangerous. This functionality is required for restoring signals. Cc: Oleg Nesterov Cc: Serge Hallyn Cc: Andrew Morton Cc: "Eric W. Biederman" Cc: Al Viro Cc: Michael Kerrisk Cc: Pavel Emelyanov CC: Cyrill Gorcunov Signed-off-by: Andrey Vagin --- kernel/signal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 7aaa51d..ac5f5e7 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2944,7 +2944,8 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, /* Not even root can pretend to send signals from the kernel. * Nor can they impersonate a kill()/tgkill(), which adds source info. */ - if (info.si_code >= 0 || info.si_code == SI_TKILL) { + if (((info.si_code >= 0 || info.si_code == SI_TKILL)) && + (task_pid_vnr(current) != pid)) { /* We used to allow any < 0 si_code */ WARN_ON_ONCE(info.si_code < 0); return -EPERM; @@ -2964,7 +2965,8 @@ long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info) /* Not even root can pretend to send signals from the kernel. * Nor can they impersonate a kill()/tgkill(), which adds source info. */ - if (info->si_code >= 0 || info->si_code == SI_TKILL) { + if ((info->si_code >= 0 || info->si_code == SI_TKILL) && + (task_pid_vnr(current) != pid)) { /* We used to allow any < 0 si_code */ WARN_ON_ONCE(info->si_code < 0); return -EPERM; -- 1.7.11.7