[PATCH] prctl: Use access_ok instead of TASK_SIZE in prctl_set_mm

From: Cyrill Gorcunov
Date: Tue Sep 25 2012 - 08:08:47 EST


Eric pointed that better to use access_ok instead
of TASK_SIZE for testing if address is allowed for
use.

Reported-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxxx>
CC: Mark Salter <msalter@xxxxxxxxxx>
CC: Kees Cook <keescook@xxxxxxxxxxxx>
CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
CC: Pavel Emelyanov <xemul@xxxxxxxxxxxxx>
---
kernel/sys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.git/kernel/sys.c
===================================================================
--- linux-2.6.git.orig/kernel/sys.c
+++ linux-2.6.git/kernel/sys.c
@@ -1865,7 +1865,7 @@ static int prctl_set_mm(int opt, unsigne
if (opt == PR_SET_MM_EXE_FILE)
return prctl_set_mm_exe_file(mm, (unsigned int)addr);

- if (addr >= TASK_SIZE || addr < mmap_min_addr)
+ if (!access_ok(VERIFY_READ, addr, sizeof(addr)) || addr < mmap_min_addr)
return -EINVAL;

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