mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kill access_ok() call from copy_siginfo_to_user() that we might as well avoid.
@ 2004-12-20 23:33 Jesper Juhl
  2004-12-21  0:18 ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2004-12-20 23:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds


Hi,

In kernel/signal.c::copy_siginfo_to_user() we are calling access_ok() 
unconditionally. As I see it there's no need for this since we might as 
well just call copy_to_user() instead of __copy_to_user() later on and 
then only get the overhead of the access_ok() check (inside 
copy_to_user()) when the  if (from->si_code < 0)  branch is actually taken.
In the case where the branch is taken the cost is the same, but when the 
branch is not taken this patch will save us an access_ok() call.

Comments are always welcome.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

diff -up linux-2.6.10-rc3-bk13-orig/kernel/signal.c linux-2.6.10-rc3-bk13/kernel/signal.c
--- linux-2.6.10-rc3-bk13-orig/kernel/signal.c	2004-12-06 22:24:56.000000000 +0100
+++ linux-2.6.10-rc3-bk13/kernel/signal.c	2004-12-21 00:23:46.000000000 +0100
@@ -2070,10 +2070,8 @@ int copy_siginfo_to_user(siginfo_t __use
 {
 	int err;
 
-	if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t)))
-		return -EFAULT;
 	if (from->si_code < 0)
-		return __copy_to_user(to, from, sizeof(siginfo_t))
+		return copy_to_user(to, from, sizeof(siginfo_t))
 			? -EFAULT : 0;
 	/*
 	 * If you change siginfo_t structure, please be sure





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-12-21  1:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-20 23:33 [PATCH] kill access_ok() call from copy_siginfo_to_user() that we might as well avoid Jesper Juhl
2004-12-21  0:18 ` Linus Torvalds
2004-12-21  0:41   ` Jesper Juhl
     [not found]     ` <Pine.LNX.4.61.0412210145260.3581@dragon.hygekrogen.localhost>
2004-12-21  0:56       ` Linus Torvalds
2004-12-21  1:25         ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®