Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1244834

[PATCH] signal: Make the si_code check in rt_[tg]sigqueueinfo stricter

From Amanieu d'Antras <amanieu@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] signal: Make the si_code check in rt_[tg]sigqueueinfo stricter
Date 2015-10-12 17:40 +0200
Message-ID <qiNmG-38X-37@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


rt_sigqueueinfo and rt_tgsigqueueinfo check the value of si_code to
prevent a process from spoofing a kernel-generated signal or one
generated by kill/tgkill.

Unfortunately this check failed to take into account the fact that
the si_code value seen by a user process is only the low 16 bits of
the value in the kernel. It was still possible to spoof any si_code
by ORing 0xffff into the top 16 bits.

The check is tightened by checking the value of si_code that will
be seen by a user program instead of the one in the kernel.

Signed-off-by: Amanieu d'Antras <amanieu@gmail.com>
---
 kernel/signal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 0f6bbbe..f3d4f39 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2989,7 +2989,7 @@ static int do_rt_sigqueueinfo(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 (((short)info->si_code >= 0 || (short)info->si_code == SI_TKILL) &&
 	    (task_pid_vnr(current) != pid))
 		return -EPERM;
 
@@ -3037,7 +3037,7 @@ static int 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 (((short)info->si_code >= 0 || (short)info->si_code == SI_TKILL) &&
 	    (task_pid_vnr(current) != pid))
 		return -EPERM;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] signal: Make the si_code check in rt_[tg]sigqueueinfo stricter Amanieu d'Antras <amanieu@gmail.com> - 2015-10-12 17:40 +0200
  Re: [PATCH] signal: Make the si_code check in rt_[tg]sigqueueinfo  stricter Oleg Nesterov <oleg@redhat.com> - 2015-10-12 18:00 +0200
    Re: [PATCH] signal: Make the si_code check in rt_[tg]sigqueueinfo stricter "Amanieu d'Antras" <amanieu@gmail.com> - 2015-10-12 18:40 +0200
      Re: [PATCH] signal: Make the si_code check in rt_[tg]sigqueueinfo  stricter Oleg Nesterov <oleg@redhat.com> - 2015-10-13 17:00 +0200
        Re: [PATCH] signal: Make the si_code check in rt_[tg]sigqueueinfo stricter "Amanieu d'Antras" <amanieu@gmail.com> - 2015-10-13 17:50 +0200

csiph-web