lkml.org 
[lkml]   [2004]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] kill access_ok() call from copy_siginfo_to_user() that we might as well avoid.

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



-
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/

\
 
 \ /
  Last update: 2005-03-22 14:08    [from the cache]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site